During the OpenRheinRuhr I noticed that a friend of mine didn’t know
about zgrep
and friends. So I told him what other grep
variations I know and he told me about some grep variations I didn’t
know about.
So here’s our collection of grep wrappers, derivatives and variations.
First I’ll list programs which search for text in different file
formats:
grep through what | Fixed Strings | Wildcards / Basic RegExps | Extended RegExps | Debian package |
---|---|---|---|---|
uncompressed text files | fgrep | grep | egrep | grep |
gzip-compressed text files | zfgrep | zgrep | zegrep | zutils, gzip |
bzip2-compressed text files | bzfgrep | bzgrep | bzegrep | bzip2 |
xz-compressed text files | xzfgrep | xzgrep | xzegrep | xz-utils |
uncompressed text files in installed Debian packages | dfgrep | dgrep | degrep | debian-goodies |
gzip-compressed text files in installed Debian packages | – | dzgrep | – | debian-goodies |
PDF documents | – | – | pdfgrep | pdfgrep |
POD texts | podgrep | – | – | pmtools |
E-Mail folder (mbox, MH, Maildir) | – | mboxgrep -G | mboxgrep -E | mboxgrep |
Patches | – | grepdiff | grepdiff -E | patchutils |
Process list | – | – | pgrep | procps |
Gnumeric spreadsheets | ssgrep -F | ssgrep | ? | gnumeric |
Files in ZIP archives | – | – | zipgrep | unzip |
ID3 tags in MP3s | – | – | taggrepper | taggrepper |
Network packets | – | – | ngrep | ngrep |
Tar archives | – | – | targrep / ptargrep | perl (Experimental only for now) |
And then there are also greps for special patterns on more or less
normal files:
grep for what | uncompressed files | compressed files | Debian package |
---|---|---|---|
PCRE (Perl Compatible Regular Expression) | pcregrep (see also the grep -P option) |
zpcregrep | pcregrep |
IP Address in a given CIDR range | grepcidr | – | grepcidr |
XPath expression | xml_grep | – | xml-twig-tools |
One question is though still unanswered for us: Is there some kind of
meta-grep which chooses per file the right grep from above by looking
at the MIME type of the according files, similar to xdg-open.
Other tools which have grep in their name, but are too special to
properly fit into the above lists:
- ext3grep: Tool to help recover deleted files on ext3
filesystems - xautomation: Includes a tool named
visgrep
to grep for subimages inside other images.
Includes contributions by Frank Hofmann and Faidon Liambotis.