Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: I need "Antigrep"

by leocharre (Priest)
on Aug 15, 2006 at 22:34 UTC ( [id://567564]=note: print w/replies, xml ) Need Help??


in reply to I need "Antigrep"

I think I get what you are asking.. ?

sick this in ~/bin/musthave and chmod 0755

#!/usr/bin/perl use strict; my ($what,$file)= @ARGV; open(HANDLE, $file); my @match = grep { /$what/ } <HANDLE>; close HANDLE; scalar @match or print STDERR "$file is missing $what\n"; exit;

then do ..
 $ find /where/my/stuff -type f -iname "*txt" -exec musthave 'I WANT THIS INN HERE' '{}' \;

What I like doing with these little things that are useful and may be used on one or a thousand files.. is to isolate the problem to *one* file, and use the system to call it multiple times (or antoher script to iterate) as needed. That way you isolate the problem into smaller parts.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found