Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2016-10-25 12:28 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (319 votes). Check out past polls.