[NTLUG:Discuss] Find Files NOT containting 'string'
Rusty Haddock
rusty at fe2o3.lonestar.org
Thu Nov 6 22:11:37 CST 2003
Stuart Johnston wrote:
>I need to search for files that contain one string but not another. Can
>anyone suggest a linux command to do this?
grep -l 'iwantthisstring' {list of files} | xargs grep -l -v 'idontwantthis'
The first grep finds all the files with 'iwantthisstring'.
The list of files from this grep is fed into xargs which
runs grep -v on those files listing the ones that do NOT
have the string 'idontwantthis'.
As I've said a number of times before, 'xargs(1)' is your friend! :-)
There's yer homework...
-Rusty-
--
_____ Rusty Haddock = KD4WLZ = rusty at fe2o3.lonestar.org
|\/ o \ o **Out yonder in the Van Alstyne (TX) Metropolitan Area**
| ( -< O o Microsoft is to software what
|/\__V__/ McDonalds is to gourmet cooking
More information about the Discuss
mailing list