[NTLUG:Discuss] Find Files NOT containting 'string'

gan hawk ganhawk1 at hotmail.com
Thu Nov 6 21:56:58 CST 2003



Sorry that should have been

cat `grep -L 'stringyoudontwant' filename` | grep 'stringyouwant'

and choose the file if there is any output.

Ganesh


>From: "gan hawk" <ganhawk1 at hotmail.com>
>Reply-To: NTLUG Discussion List <discuss at ntlug.org>
>To: discuss at ntlug.org
>Subject: Re: [NTLUG:Discuss] Find Files NOT containting 'string'
>Date: Thu, 06 Nov 2003 21:51:00 -0600
>MIME-Version: 1.0
>X-Originating-IP: [129.110.94.197]
>X-Originating-Email: [ganhawk1 at hotmail.com]
>Received: from mc1-f26.hotmail.com ([64.4.50.33]) by mc1-s21.hotmail.com 
>with Microsoft SMTPSVC(5.0.2195.6713); Thu, 6 Nov 2003 19:52:14 -0800
>Received: from ntlug-2001.ntlug.org ([216.234.235.154]) by 
>mc1-f26.hotmail.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 6 Nov 2003 
>19:51:40 -0800
>Received: from localhost ([127.0.0.1] helo=ntlug-2001.ntlug.org)by 
>ntlug-2001.ntlug.org with esmtp (Exim 4.24)id 1AHxep-0005Oo-TH; Thu, 06 Nov 
>2003 21:51:35 -0600
>Received: from bay10-f101.bay10.hotmail.com ([64.4.37.101] 
>helo=hotmail.com)by ntlug-2001.ntlug.org with esmtp (Exim 4.24)id 
>1AHxel-0005Ob-TQfor discuss at ntlug.org; Thu, 06 Nov 2003 21:51:31 -0600
>Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; 
>Thu, 6 Nov 2003 19:51:01 -0800
>Received: from 129.110.94.197 by by10fd.bay10.hotmail.msn.com with 
>HTTP;Fri, 07 Nov 2003 03:51:00 GMT
>X-Message-Info: KtxBqYfPyq36K1Sc+F60m2wtmTDdbNjg
>Message-ID: <BAY10-F101ZD3bAirgR0003ea75 at hotmail.com>
>X-OriginalArrivalTime: 07 Nov 2003 03:51:01.0124 
>(UTC)FILETIME=[5C196C40:01C3A4E2]
>X-Spam-Status: No, hits=-4.7 required=5.0tests=BAYES_10version=2.55
>X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 
>(1.174.2.19-2003-05-19-exp)
>X-BeenThere: discuss at ntlug.org
>X-Mailman-Version: 2.1
>Precedence: list
>List-Id: NTLUG Discussion List <discuss.ntlug.org>
>List-Help: <mailto:discuss-request at ntlug.org?subject=help>
>List-Post: <mailto:discuss at ntlug.org>
>List-Subscribe: 
><https://ntlug.org/mailman/listinfo/discuss>,<mailto:discuss-request at ntlug.org?subject=subscribe>
>List-Archive: </pipermail>
>List-Unsubscribe: 
><https://ntlug.org/mailman/listinfo/discuss>,<mailto:discuss-request at ntlug.org?subject=unsubscribe>
>Sender: discuss-bounces at ntlug.org
>Errors-To: discuss-bounces at ntlug.org
>X-SA-Exim-Mail-From: discuss-bounces at ntlug.org
>X-SA-Exim-Scanned: No; SAEximRunCond expanded to false
>Return-Path: discuss-bounces at ntlug.org
>
>
>Hi,
>
>If I understand correctly, you want the list of files that contains 'string 
>you want' but does not contain 'string you dont want'
>
>cat `grep -l 'stringyouwant' filename` | grep 'stringyoudontwant'
>
>If there is any output then you dont want this file.
>
>Remember that -l option returns after first match. So you will have to put 
>this in a loop and print the filename if there is no output.
>
>
>Ganesh
>
>
>
>>From: Stuart Johnston <sjohnston at vaultranet.com>
>>Reply-To: NTLUG Discussion List <discuss at ntlug.org>
>>To: NTLUG Discussion List <discuss at ntlug.org>
>>Subject: [NTLUG:Discuss] Find Files NOT containting 'string'
>>Date: Thu, 06 Nov 2003 19:01:54 -0600
>>MIME-Version: 1.0
>>Received: from mc6-f22 ([65.54.252.158]) by mc6-s17.hotmail.com with 
>>Microsoft SMTPSVC(5.0.2195.5600); Thu, 6 Nov 2003 17:02:07 -0800
>>Received: from ntlug-2001.ntlug.org ([216.234.235.154]) by mc6-f22 with 
>>Microsoft SMTPSVC(5.0.2195.5600); Thu, 6 Nov 2003 17:01:22 -0800
>>Received: from localhost ([127.0.0.1] helo=ntlug-2001.ntlug.org)by 
>>ntlug-2001.ntlug.org with esmtp (Exim 4.24)id 1AHuzB-0003xL-AL; Thu, 06 
>>Nov 2003 19:00:25 -0600
>>Received: from 69-56-130-154.theplanet.com 
>>([69.56.130.154]helo=mail.haisolutions.com)by ntlug-2001.ntlug.org with 
>>esmtp (Exim 4.24)	id 1AHuz6-0003xE-Vwfor discuss at ntlug.org; Thu, 06 Nov 
>>2003 19:00:20 -0600
>>Received: from vaultranet.com (207-90-217-50.crescentb.com 
>>[207.90.217.50])by mail.haisolutions.com (Postfix) with ESMTP id 
>>103BD7F421Efor <discuss at ntlug.org>; Thu,  6 Nov 2003 19:11:28 -0600 (CST)
>>X-Message-Info: KtxBqYfPyq1jL7M/5k9xNKP0lm2WbTFZ
>>Message-ID: <3FAAEF02.4040806 at vaultranet.com>
>>User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031021
>>X-Accept-Language: en-us, en
>>X-Spam-Status: No, hits=-5.4 
>>required=5.0tests=BAYES_01,USER_AGENT_MOZILLA_UAversion=2.55
>>X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 
>>(1.174.2.19-2003-05-19-exp)
>>X-BeenThere: discuss at ntlug.org
>>X-Mailman-Version: 2.1
>>Precedence: list
>>List-Id: NTLUG Discussion List <discuss.ntlug.org>
>>List-Help: <mailto:discuss-request at ntlug.org?subject=help>
>>List-Post: <mailto:discuss at ntlug.org>
>>List-Subscribe: 
>><https://ntlug.org/mailman/listinfo/discuss>,<mailto:discuss-request at ntlug.org?subject=subscribe>
>>List-Archive: </pipermail>
>>List-Unsubscribe: 
>><https://ntlug.org/mailman/listinfo/discuss>,<mailto:discuss-request at ntlug.org?subject=unsubscribe>
>>Sender: discuss-bounces at ntlug.org
>>Errors-To: discuss-bounces at ntlug.org
>>X-SA-Exim-Mail-From: discuss-bounces at ntlug.org
>>X-SA-Exim-Scanned: No; SAEximRunCond expanded to false
>>Return-Path: discuss-bounces at ntlug.org
>>X-OriginalArrivalTime: 07 Nov 2003 01:01:22.0491 (UTC) 
>>FILETIME=[A92948B0:01C3A4CA]
>>
>>I need to search for files that contain one string but not another.  Can 
>>anyone suggest a linux command to do this?
>>
>>The first part is easy with grep but since grep is line based it doesn't 
>>work will for the second part since pretty much every file will have at 
>>least one line that does not contain the string.
>>
>>I guess one way would be to grep a list of files containing the second 
>>string and compare it against the list of files that contain the first but 
>>I can't think how to easily XOR the two lists of files.  I don't want to 
>>ask you to 'do my homework' for me but if you can pull a command of the 
>>top of your head, I would appreciate it.
>>
>>thanks,
>>Stuart Johnston
>>
>>
>>_______________________________________________
>>https://ntlug.org/mailman/listinfo/discuss
>
>_________________________________________________________________
>Crave some Miles Davis or Grateful Dead?  Your old favorites are always 
>playing on MSN Radio Plus. Trial month free! 
>http://join.msn.com/?page=offers/premiumradio
>
>
>_______________________________________________
>https://ntlug.org/mailman/listinfo/discuss

_________________________________________________________________
MSN Shopping upgraded for the holidays!  Snappier product search... 
http://shopping.msn.com




More information about the Discuss mailing list