scratch/content/html/en/blog/02_ackgrep.md
2010-03-30 16:39:12 +02:00

1.8 KiB

created_at kind title multiTitle multiDescription menupriority
2009-07-22T16:15:23+02:00 article Better than Grep
fr en
Mieux que grep Better than Grep
fr en
grep avec de la coloration syntaxique sur de multiples fichiers. Pour rechercher une chaine de caractère efficacement dans de nombreux fichiers. grep on multiple files with syntax coloring in one simple command. In order to find efficiently a string within many files.
1

update

As Andy Lester told me ack is a simple file you only have to copy in your ~/bin folder. Now I've got ack on my professional server.

Go on http://betterthangrep.com to download it.

Sincerely, I don't understand ack don't become a common command on all UNIX systems. I can no more live without. For me it is as essential as which or find.

newcorps

Better than grep

One of the my main usage of grep is

grep 'pattern' **/*(.)

Most of time it is enough. But it is far better with colored output. ack-grep in Ubuntu does that. As I couldn't install it on my 'Evil Company Server', I had done one myself in very few lines:

#!/usr/bin/env zsh (($#<1)) && { print 'usage: ack "regexp"' >&2; exit 1 }

listeFic=( **/(.) ) autoload zargs zargs -- $listeFic -- grep $1 | perl -ne 'use Term::ANSIColor; if (m/([^:])(:.)('$1')(.)/) { print color("green").$1; print color("reset").$2; print color("black","on_yellow").$3; print color("reset").$4."\n"; } '

For my team and I it is usable enough. I hope it could help.