MonadLUG's 12-Oct Meeting: grep and open chat
Kevin D. Clark
kclark at elbrysnetworks.com
Mon Oct 30 15:53:45 EST 2006
Ted Roche <tedroche at tedroche.com> writes:
> A corrected set of notes is here:
>
> http://www.mv.com/ipusers/ke1g/grep.html
>
> it was a great overview of the command with some good pointers on
> gotchas, especially the point that grep processes line-by-line, so a
> pattern match over a line boundary will not be seen.
I actually find that I have to grep whole files on occasion. My
general recipe for finding a file that contains both "foo" and "bar"
(on any line) goes like this:
perl -0777 -ne 'print "$ARGV\n" if (/foo/ && /bar/);'
...where -0777 puts Perl into "slurp mode" and (of course) "-ne" will
be familiar to any sed programmer.
Perl's regexps handle multi-lines too. See the /s modifier.
I use this all the time to (for example) perform complicated searches
on my Maildir.
Regards,
--kevin
--
GnuPG ID: B280F24E Never could stand that dog.
alumni.unh.edu!kdc -- Tom Waits
More information about the gnhlug-discuss
mailing list