Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: grep -P

by sgifford (Prior)
on Jun 26, 2006 at 01:46 UTC ( [id://557500] : note . print w/replies, xml ) Need Help??


in reply to grep -P

If you don't need the more complex command-line options of grep, you can just use perl -ne 'print if (/pat/)'. Even the trickier options usually come down to just a small variation on that theme.

Replies are listed 'Best First'.
Re^2: grep -P
by tomazos (Deacon) on Jun 26, 2006 at 03:08 UTC
    I guess -R (recurse directory) and -l (print filenames containing matches) are two that I use often. The one liner is a bit of a mouthful.

    But just for fun:

    perl -MFile::Find -ne 'find(& sub { $f = 1; if (/pat/ and $f) { $f = 0 +; print $File::Find::name . "\n" }, "mydir");'

    ...or something like that.

    -Andrew.