Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by codeacrobat (Chaplain)
on Jan 30, 2007 at 07:18 UTC ( #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
Node Status?
node history
Node Type: note [id://597304]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2016-12-03 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.