I 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.
Agreed, 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.
https://github.com/stedolan/jq
https://github.com/ggreer/the_silver_searcher
"The command name is 33% shorter than ack!"