Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://597304]
holli just tried to open a soda bottle with a bottleopener
[holli]: ok, that doesn't *sound* that bad
[Corion]: holli: Was it a "twist-to-open" soda bottle? Or a German Mehrweg bottle with a twisty cap?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2017-09-25 12:32 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (280 votes). Check out past polls.