Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-07-26 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (178 votes), past polls