4 ms·
You should probably read the release notes for new major versions. Also, anytime you think “I wish there was <feature> available in this program”, you should p
by teddyh 2y ago
You should probably read the release notes for new major versions. Also, anytime you think “I wish there was <feature> available in this program”, you should probably double-check if such a feature has appeared since you last learned the program.
- dredmorbius 2y agoThat's how I discovered the '&' regex feature in less some years back.
- teddyh 2y agoDo you mean PCRE’s “(?&name)” feature? That is not portable; for instance, Python calls it “(?P=name)”. Or do you mean the common feature of “&” in the replacement string meaning “the whole matched string”? While this feature is common in languages which use regexps (including ed, sed, awk, etc.), that’s not actually a regexp feature, since the & character has that effect in the replacement string, not in the regular expression. It is also not always portable; for instance, Emacs requires escaping as \& for the character to have the special feature.
- dredmorbius 2y agoFrom man(1) less: &pattern Display only lines which match the pattern; lines which do not match the pattern are not displayed. If pattern is empty (if you type & immediately followed by ENTER), any filtering is turned off, and all lines are displayed. While filtering is in effect, an ampersand is displayed at the beginning of the prompt, as a reminder that some lines in the file may be hidden. $ less --version less 487 (GNU regular expressions) Copyright (C) 1984-2016 Mark Nudelman
- teddyh 2y agoOh, you meant the program “less”! Right, I understand what you meant now.
- dredmorbius 2y ago:-) Yeah. I was viewing some files and thinking "it'd be really cool if less(1) had some way of filtering to just lines matching a specific pattern". RTFM'd and TIL'd. Mind that at that point I'd used less for ... oh, at least 30 years.
- sgarland 2y agoAgreed. This is also how I found out that features in Python I took for granted, like breakpoint(), were much more recent than I thought (3.7). Nothing like having to use ancient versions of a language to discover limitations.