4 ms·
Looking at the jq github repo led me to also find ag, an ack-grep replacement. Both are in my distro's repositories. https://github.com/stedolan/jq https://git
by a3n 10y ago
Looking at the jq github repo led me to also find ag, an ack-grep replacement. Both are in my distro's repositories.
https://github.com/stedolan/jq https://github.com/stedolan/jq
https://github.com/ggreer/the_silver_searcher https://github.com/ggreer/the_silver_searcher
"The command name is 33% shorter than ack!"
- baq 10y agoSkip ag and go straight to rg (ripgrep).
- idsout 10y agoNow check out ripgrep (command `rg`) https://github.com/BurntSushi/ripgrep https://github.com/BurntSushi/ripgrep, the ag/ack killer ;).
- danso 10y agoI like ag, but unless I'm missing something, ack has this killer flag which ag lacks: --output=expr Output the evaluation of expr for each line (turns off text highlighting) If PATTERN matches more than once then a line is output for each non-overlapping match. For more information please see the section "Examples of --output". Basically, it allows you to use captured groups in the output: cat file | ag '(\w+) (\d+)' --output '$1 is $2 years old' On the other hand, ag allows multiline matching. So I end up using ag and ack together frequently.
- mVChr 10y agosed -rn 's/([a-zA-Z]+) ([0-9]+)/\1 is \2 years old/p' file
- danso 10y agosed doesn't support the same PCRE regex ack or ag
- mVChr 10y agoNo, but the `-r` option makes it use extended regex[1]. Here's some PCRE: cat file | perl -ne 'print if s/(\w+) (\d+)/\1 is \2 years old/' My only point is sometimes old school standard tools are plenty. 1: https://www.gnu.org/software/sed/manual/sed.html#Extended-regexps https://www.gnu.org/software/sed/manual/sed.html#Extended-re...
- danso 10y agoRight...but there's a point in having a tool that does PCRE, and all the things useful in grep, in one command, rather than kicking out to Perl.
- a3n 10y agoAgreed, it's nice to consolidate disparate functionality into a single invocation. But when I saw mVChr's sed line, and then again the perl line, I was reminded "Oh, right, old school." And I wondered for the Nth time how much of old school has been unknowingly reinvented, and how many times. Nevertheless, I like the new(er) tools in this thread too.
- burntsushi 10y agoripgrep has that with -r/--replace.