grep Pocket Reference is the first guide devoted to grep, the powerful Unix content-location utility. This handy book is ideal for system administrators, security professionals, developers, and others who want to learn more about grep and take new approaches with it -- for everything from mail filtering and system log management to malware analysis. With grep Pocket Reference, you will:
Learn methods for filtering large files for specific content
Acquire information not included in the current grep documentation
Get several tricks for using variants such as egrep
Keep key information about grep right at your fingertips
Find the answers you need about grep quickly and easily. If you're familiar with this utility, grep Pocket Reference will help you refresh your basic knowledge, understand rare situations, and work more efficiently. If you're new to grep, this book is the best way to get started.
Chapter 1 grep Pocket Reference
Introduction to Regular Expressions
Basic Regular Expressions (grep or grep -G)
Extended Regular Expressions (egrep or grep -E)
Fixed Strings (fgrep or grep -F)
Perl-Style Regular Expressions (grep -P)
Introduction to grep-Relevant Environment Variables
Choosing Between grep Types and Performance Considerations
John Bambenek is a programmer and teacher with over ten years of experience. His work at the Internet Storm Center and the University of Illinois, as well as his contributions to SANS information management courses, will help him promote this book and give him a sound base from which to write.
Agnieszka Klus was born in Rzeszow, Poland and came here as a child. She lives in the northwest suburb of Chicago, but considers herself a Chicagoan. She is currently trying to get her Masters in Accountancy at the University of Illinois at Urbana-Champaign, and also works as a system administrator at the Coordinated Science Laboratory.
This pocket reference has a lot of errata, perhaps the most glaring of which is the link to the errata page: http://www.oreilly.com/catalog/9780596153601 (on pg. 4) which does not exist. I'm very disappointed by the quality of O'Reilly's proofreading staff (if indeed any were employed for this product) and their apparent lack of concern for propagating corrections. Just a few examples:
The '-l' option is listed twice, once as '--files-with-matches' (pg. 30) and once as '--binary-files=without-match' (pg. 36). (The latter should be '-I', on both pgs. 35 & 36.)
Forward slash ('/') and backslash ('\') are confused several times under PCRE "Octal Searching" on pg. 46 and again for hex searches on pg. 60.
In addition, the command given on page 60 for hex searching: grep '[\xabaa]' doesn't work as intended.
$ echo -e '\xab\xaa\n\xab\xaa' | grep '[\xabaa]'
gives no output. The given grep command is actually a character class search for the characters 'x', 'a', & 'b', as shown here:
$ echo -e 'xab\nxab' | grep '[\xabaa]' xab xab
The correct command would use -P and no brackets (here in an emacs shell buffer):
The statement on pg. 14: "Used alone it will match every line in a stream except the final line, which is terminated by an "end of file" character instead of an "end of line" character." is also incorrect, as this example in a Unix shell shows:
$ echo 'abc > def > ghi' | grep '$' abc def ghi
(I haven't seen an "end of file" (EOF) "character", since ancient DOS, which used Control-Z, and even that was optional.)
This assertion: "For instance, [:upper:] can also be written as [A-Z] and uses ..." (pgs. 20-21) is only partially true (i.e., for ASCII/English).
The first piping example on page 25: cat editinfo | grep Smith | grep -v hi.txt will work, but should probably be: cat editinfo | grep Smith | grep -v 'hi\.txt' to reinforce the discussion of the \ (escape) character on pg. 13.
The second (shorter) example at the bottom of page 25 doesn't work at all. (It sits waiting for input from stdin for the first command.): grep Smith | grep -v hi.txt
The discussion of 'fgrep -b' on pg. 42 mixes block number and byte number. They are not the same.
"... PCRE can search from a character in hex format ..." should be "for a character". (pg. 46)
Even a non-technical editor or proofreader should be able to catch awkward or incorrect English like this:
"The results of this simple command: 'install.*file' the results should output ..." (pg 15)
"When a search can be accomplished using fewer commands or with fewer decisions having to be made, the more efficiently it will behave." (pg. 26)
"... if you want to monitor a logfile in real-time for specified content, she could use the following command: ..." (pg. 26)
"To use this, the \p or \P sequence is used." (pg. 46)
The Pocket Guide is still useful as a reference, but I would like to have seen fewer errors and a real errata page.
Bottom Line Yes, I would recommend this to a friend
I needed a book that would teach me REGEX and how better to use grep/fgrep, but without having to learn PERL and JAVA. (ie. Master Regular Expressions contains over half the data relevant to other languages.)
This "grep Pocket Reference" did a good job of explaining the grep options in tandem with the it's Manual Page. Although few, I thought the examples near the end were great. However, the examples seemed to be themed on personal private data searching rather then something more relevant to a computer users -- but they could easily be converted.
This EBook needs some corrections (a reprint including errata?) as it contains some grammar or run-on sentences which conflict and provide incorrect data. Also, there's a sentence in the book stating, in effect, it's OK or legal to use fgrep to search other peoples EMail. I'm no lawyer, but this doesn't sound correct. Again, those few sentences probably need a little rewording.
All in all, besides the fact it needed a good proof reading -- the book taught me what I needed to learn about grep as it's manual page lacks examples and a certain amount of clarity. (Currently, grep's manual page is written like a specification rather then something focused towards a user, omitting example usage.)
(There is a small chapter on Perl REGEX. ie. --perl-regexp)
If you need a book to learn REGEX and have a little trouble with the GREP Manual Page, or don't want to read a huge book like Mastering REGEX, get this book for learning REGEX (aka BRE/ERE).
Also noteworthy, the MOBI formated EBook version of this "grep Pocket Reference" is the first readable MOBI EBook I've been able to read so far on my Kindle DXG. This book had few TABLE TAGS (or computer technical drawings/coding). And of the presented console/terminal text presented, it was readable unlike many other MOBI technical books I've tried to read.
Bottom Line Yes, I would recommend this to a friend