Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ack to the future!

Ack to the future!

Why you should use ack, and what's coming in ack 2.0 and beyond.

Andy Lester

June 14, 2012
Tweet

More Decks by Andy Lester

Other Decks in Programming

Transcript

  1. ack to the future Andy Lester & Rob Hoelz YAPC::NA

    2012, June 14, Madison, WI Thursday, June 14, 12
  2. Recognizes filetypes • --perl matches *.pm, *.pl, *.t • and

    scripts without extensions that begin with a #!...perl shebang line • Same with Python, PHP, Ruby, etc Thursday, June 14, 12
  3. Ignores junk • .git, .svn, .hg, etc • coredumps •

    binary files • blib, _build, nytprof • *~ backups Thursday, June 14, 12
  4. Perl regexes • True Perl regexes, not PCRE. • Use

    $1, $&, etc ‣ ack '#include\s*"(.+)"' --output='$1' Thursday, June 14, 12
  5. Portable, Windows • Works back to Perl 5.8.8 • Only

    one dependency, File::Next • Works on Windows when you have no other Unixy tools Thursday, June 14, 12
  6. Easy install • Install as App::Ack from CPAN • -or-

    • Install a package (might be "ack-grep" for your distro) • -or- • DL single file from betterthangrep.com Thursday, June 14, 12
  7. Optimized for laziness • Typing grep switches is slow •

    DIY aliases + shell configs are not portable Thursday, June 14, 12
  8. Flexible file/dir selectors • Making types is easier! • --type-add=make:match:/^[mr]akefile/i

    • --type-add=perl:firstlinematch:/perl/ • Making exclusions is easier! • --ignore-file=Makefile.PL • --ignore-dir=cache/ Thursday, June 14, 12