Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm doing cleanup on a large codebase.

It would be useful for me to identify files NOT containing certain patterns, eg files missing an initiation or configuration string, or that kind of thing.

I initially thought I could do this with grep -vl, but no dice. It doesn't work, because grep -vl compares line by line, so if any LINE doesn't contain the pattern, the file is flagged as not containing the pattern.

I tracked down a script called grepcat which supposedly does what I want (haven't tried it).

Seems a bit kludgy to me though, and a good candidate for doing in perl instead.

So, anybody got a quickie perl script to do the OPPOSITE of grep? I just want the filenames, not the non matching lines. Should work as follows

hartman@ds0207:~/filesContainingArena> find | xargs -ti cat {} cat . cat: .: Ist ein Verzeichnis cat ./a a cat ./b b a cat ./c c a hartman@ds0207:~/filesContainingArena> antigrep.pl c * # should return + files not containing c, eg a and b, but not c. bash: antigrep.pl: command not found hartman@ds0207:~/filesContainingArena> grep -vl c * #unfortunately thi +s doesn't work a b c hartman@ds0207:~/filesContainingArena>

Alternatively, I should be able to do antigrep with

find | xargs antigrep.pl I'd really like to do this in a one-liner, but can't quite think how.

Much obliged!


In reply to I need "Antigrep" by tphyahoo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found