Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Grep for a sentence in windows directory

by Athanasius (Abbot)
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 taking refuge in the Monastery: (18)
As of 2015-07-06 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls