Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Grep for a sentence in windows directory

by Athanasius (Chancellor)
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

Athanasius <°(((><contra mundum

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000105]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2017-07-21 22:56 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (336 votes). Check out past polls.