[NTLUG:Discuss] Find Files NOT containting 'string'
Rusty Haddock
rusty at fe2o3.lonestar.org
Fri Nov 7 10:26:44 CST 2003
Robert Citek wrote:
>
>At 07:01 PM 11/6/2003 -0600, 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?
>
>At 10:32 PM 11/6/2003 -0600, Rusty Haddock wrote:
>>grep -l 'iwantthisstring' {list of files} | xargs grep -L 'idontwantthis'
>
>Sample input files:
>
>echo -e "abc\ndef" > x-abc\ def
>echo -e "def\nghi" > x-def\ ghi
>echo -e "ghi\njkl" > x-ghi\ jkl
>echo -e "jkl\nabc" > x-jkl\ abc
Files names with spaces in them. Oh, that is sooooo ugly. :-P
And so Windowsesque. :-)
>$ grep -Z -l "abc" x-* | xargs -0 grep -L "def"
>x-jkl abc
>
>> >As I've said a number of times before, 'xargs(1)' is your friend! :-)
>>Still true though.
>Yup.
Someone's been down this path before...
Daggummit, that's three options to xargs and grep that I've learned
in 24-hours. 'preciate it though!
-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