Follow

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 @xhr@mastodon.social 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.

@xhr@mastodon.social @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.

@_xhr_
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 :)

@_xhr_ @ed1conf maximize or alt-RMB?😇
(to lead to these windowmanager things I discovered years after I should have... and yes I feel like I still could find something new in vi or sed each damn day...)

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

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

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

@_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.

@_xhr_
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

forever.

If it supports PCRE I'll be *so* happy

@_xhr_ well wallop me with a wet fish I did not know this gem either

@xhr@mastodon.social There's always something cool to learn!

@_xhr_

> ("&" 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: github.com/tootsuite/mastodon/).

@_xhr_ inb4 "WHY WOULD YOU DO THAT?! JUST PIPE THE OUTPUT OF GREP INTO LESS!"

@_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

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!