Wow, after 25 years of Unix experience, I learned that you can filter output in .

Press ampersand (&) and enter a regex to show only lines matching the regex.

Press ampersand (&) and then exclamation mark (!) to apply an inverse filter.

@ParadeGrotesque yeah, I also didn't know that and I've used Unix since the late 80's.

Since you said that you've used Unix for 25 years, I was surprised it was that old. I checked, and it turns out that it was released 37 years ago. That's pretty impressive.

@loke @ParadeGrotesque Unix is even older. The first version was released beginning of the 1970ies. @ParadeGrotesque yes, I was referring to less, not Unix.

I remember downloading less and installing it on our VAX 11/750 that we had at the local computer club. We were running BSD 4.3 on it.

We may even have installed it on the previous machine we had, that was running SysV. I'm not sure what version.

@loke @ParadeGrotesque Ah, OK. I was mistaken then 😜

VAX and 4.3BSD was before my time. @ParadeGrotesque yeah, I re-read my reply and I understand how it could be misunderstood. In fact, I wrote it really poorly

I use this all the time since discovering it and try to share it regularly.

If you're looking for other obscure corners in less(1)

you can use "-S" (in a running session of less) to toggle between wrapping and not-wrapping long lines. Most toggleable options can do this, so if you pipe ANSI output to less and see a bunch of "ESC" sequences, try typing "-R" to toggle ANSI-sequence processing/display. Or "-i"/"-I" to toggle case-sensitivity in searches.

@ed1conf Awesome, thanks for letting me know. I usually just maximized my terminal window to deal with wrapping lines :)

@ed1conf @_xhr_ That -S is really nice in Linux/systemd's journalctl output where the wrapped lines always annoy me.

I just like the fact that I can go up and down.. less is more but better!

@ed1conf 😟🤦🏽‍♂️All these years of restarting the command, and I can be toggled in session.😓

@ed1conf @_xhr_ My favorite is invoking less with +G as a flag; it lets you read the file starting at the end

@_xhr_ you can also customize your keys and a few different exit codes. That's what #bollux does for #gemini browsing

@_xhr_ Nice tip, i didn’t Know. I should read more man.

@_xhr_ Btw. negation (with "!") also works in the normal search prompt.

Other useful keys:
- "=" shows info about the current file and its position in the file
- "F" keeps scrolling to the end oft the file (like the "tail" command)
- Escape key followed by "F" works like "F", but stops scrolling when the current search pattern is found - ie. it keeps scrolling until something interesting is found.

Definitely didn't know this - thanks for sharing!

@_xhr_ I wonder if threre is already a Rust rewrite of less that has this feature too.

@_xhr_ Thanks so much for that.

I will admit that, till I read this, I was using a version of less too old to have that feature.🙃

@babelcarp @_xhr_ Aha, that's why I didn't know about this. I swear I read the less man page, but probably 25 years ago

@_xhr_ whoa, I've been using

... | grep «regex» | less


If it supports PCRE I'll be *so* happy There's always something cool to learn!


> ("&" command within less)

You are kidding me. I've been using Unix for around 40 years (before less, come to that) and this is a new one to me, too.

Thanks! 👍

@_xhr_ Nice, now I won't have to install #ed on anti-POSIX machines…

@_xhr_ just read this and it made me wonder if i could pipe `tail -f` into fzf and do fuzzy finding in real time. Turns out you can 🤯

@_xhr_ Another cool thing is jumping between the paired parentheses with the (), [] and {} keys. Absolutely great for browsing JSON if you happen to have it open in `less` and not some text editor with this capability exposed in a more obvious way.

A generalized version is Ctrl+Alt+F/B followed by two characters forming a pair to jump between.

Also in case someone doesn't know — G (shift+G) scrolls to the end, and numberG scrolls to specified line number. In general, if you know vim, some of those arcane key sequences work in less as well.

@fuyuhikodate @_xhr_ I remember the day when I was one of the 10,000 who discovered that XKCD had tooltip punchlines!

@_xhr_ Übrigens, dieser eine Toot und die 108 Retoots haben dazu geführt, dass das "less"-Hashtag hier seit gestern dauerhaft in den Trends steht :-D

(das ist wohl eine Änderung in dem ganz neuen #Mastodon 3.4.0:


@_xhr_ I know, right? Every time I start spending time in console I end up in the man pages.

@_xhr_ Constantly learning new stuff in BSD & Linux like these CLI tips & tricks - keeps stuff new and exciting. Good stuff!

@_xhr_ I have done this a few times by accident and been very confused by it. The characters & and / are next to each other on my keyboard layout. Now I know! thanks

@_xhr_ You keep learning new things. Unix/Linux is pretty friggin vast.

These past 14 days I've learned a lot about Socat, been sharing it with a colleague, and I must admit I am once again amazed at the power of the 'everything is a file' concept.

@RasmusLindegaard socat is a very nice tool. And I assume that most Unix people doesn't know about it, so good that you shared your knowledge.

@_xhr_ It's like magic. But then: The Unix/Linux commandline really is like magic in general.

@_xhr_ thanks to this toot I learned those after 4 years of Unix experience, thanks. :gnu:

Sign in to participate in the conversation

The original server operated by the Mastodon gGmbH non-profit