Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: search for a pattern in file without opening the file

by codeacrobat (Chaplain)
on Jan 30, 2007 at 07:18 UTC ( [id://597304]=note: print w/replies, xml ) Need Help??


in reply to search for a pattern in file without opening the file

Let perl do the dirty work and use the implicit loop options -n ( see perlrun ).

Check out Tim Mahers Minimal Perl if you are a unixy person and want perl scripts to work similar to unix tools.

/usr/bin/perl -n BEGIN{ @ARGV=qw(the files you want to process); } push @files, $ARGV and close ARGV if /^pattern/; END{ print "matching files @files\n" }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://597304]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-03-28 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found