Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Grep for a sentence in windows directory

by Athanasius (Monsignor)
on Oct 20, 2012 at 06:50 UTC ( #1000105=note: print w/ replies, xml ) Need Help??


in reply to Grep for a sentence in windows directory

Here is a one-liner you can use:

>cd c:\dropbox >perl -Mautodie -E "local $/; @f = grep { if (-f) { open($fh, '<', $_) +; <$fh> =~ / connection failed/ && $_ } } glob('*'); say qq[@f];"

(But I’m sure there are more elegant solutions.)

Update: Using ack, as Anonymous Monk suggests, is as simple as:

>cd c:\dropbox >ack -ln " connection failed"

The -l switch causes filenames to be output instead of the matching lines, and the -n switch prevents recursion into subdirectories. See also http://betterthangrep.com/.

Athanasius <°(((><contra mundum


Comment on Re: Grep for a sentence in windows directory
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2014-09-19 14:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (140 votes), past polls