Skip to content

Comment on Time-saving tips for Linuxparent

Comments

Could you give an example of something useful one could do with ack's --output feature?

The manual's a little light on the details.

All it says is:

  --output=expr
     Output the evaluation of expr for each line
What expression are they talking about? A regular expression? If so, how is that different from a normal grep?

A Perl expression. You could use this for sed-like activities:

    # Print included files.
    ack --output '$1' '#include <(.*)>'
You could presumably do much trickier things as well, since the --output argument can contain any Perl expression.

That's a great example. I just replaced it as the example in the Top 10 List on the front of betterthangrep.com. Thanks.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.