From owner-freebsd-questions@FreeBSD.ORG Sat May 30 12:22:52 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8DF7106564A for ; Sat, 30 May 2009 12:22:52 +0000 (UTC) (envelope-from valentin.bud@gmail.com) Received: from mail-bw0-f213.google.com (mail-bw0-f213.google.com [209.85.218.213]) by mx1.freebsd.org (Postfix) with ESMTP id 5F1FA8FC1B for ; Sat, 30 May 2009 12:22:51 +0000 (UTC) (envelope-from valentin.bud@gmail.com) Received: by bwz9 with SMTP id 9so6741310bwz.43 for ; Sat, 30 May 2009 05:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=1oVNcVqixYWQvOJkO1kSKb2J+Ot4N8GkGekiOuJtRKw=; b=uoLenlhFU+nbOLeCfsm2d1ovwvSB6T6lDLGcazgj5nBJRC6oxpi3b6YdhDdEHhBKyo MqlAKoknK0ndGmldvAxvpHb5cengbCFtPFfqfwRk8TWfuBRIbfi8moXjbf7I7wqBs4x0 e3ra8eIBuSp0rnhu8Pu6uHXqOxTzipwrk/KAo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=LMXn3zA7IYmwuugbyrHYABQEEEeAcNX9RYhBTdXzmefzVQg1365pKjJbDEFXZbN85E o2yNG/u3D3cmlDwD0Aw2wQQF5dmnkJk/FXUaedxGCzlazKcJgxIWbWaJSNkvSNZtyH9O CrG56p+B01XoIGboMMQJcTG2tL8PU2shHEEpI= MIME-Version: 1.0 Received: by 10.103.223.2 with SMTP id a2mr2236312mur.4.1243686170103; Sat, 30 May 2009 05:22:50 -0700 (PDT) In-Reply-To: <200905301412.50958.mel.flynn+fbsd.questions@mailing.thruhere.net> References: <80cddf609e38046ffa0ce3f2bdab235c.squirrel@relay.lc-words.com> <139b44430905300456x62bf9c0ybf46bcab6b64e25@mail.gmail.com> <200905301412.50958.mel.flynn+fbsd.questions@mailing.thruhere.net> From: Valentin Bud Date: Sat, 30 May 2009 15:22:30 +0300 Message-ID: <139b44430905300522i21c06725nc17d3bd12573c858@mail.gmail.com> To: Mel Flynn Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org, Zbigniew Szalbot Subject: Re: find and searching for specific expression in files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2009 12:22:53 -0000 On Sat, May 30, 2009 at 3:12 PM, Mel Flynn < mel.flynn+fbsd.questions@mailing.thruhere.net > wrote: > On Saturday 30 May 2009 13:56:22 Valentin Bud wrote: > > 2009/5/30 Zbigniew Szalbot > > > > > >> Can you please give me a hint how to use find to search for a > specific > > > >> text within files? > > > > > > > > Generally, you don't - find(1) does not examine the contents of files > > > > by itself, just their directory information. You normally use > grep(1) > > > > to search within a file. > > > > > > Ahhh - I use grep on daily basis. Now why didn't I think of it? I got > so > > > fixed on the idea of using find that I completely forgot about grep.... > > > > > > Sorry for the noise and thank you very much for your help! > > > > > > -- > > > Zbigniew Szalbot > > > > > > _______________________________________________ > > > freebsd-questions@freebsd.org mailing list > > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > > To unsubscribe, send any mail to " > > > freebsd-questions-unsubscribe@freebsd.org" > > > > Hello Mr. Zbigniew Szalbot, > > > > You can use egrep -r * (grep -e) to search for specific text pattern > while > > you are in a directory with many sub directories. The output is nice > > because it tells you the file in which the text pattern was found :). > > Discouraged because: > - it's possible to hit maxarglen if the root directory has many > subdirectories. Never occured so i didn't have a clue about it :|. > > - Will not search hidden directories in the root directory because of the > shell glob > - cannot be combined with other search criteria such as the file's > timestamp. > > find . -type f -mtime 2 -exec grep '^Subject: \[SPAM\]' {} + > > will find all messages in a maildir modified within the last 2 minutes > where > the subject has been flagged as spam. I use + rather then ; so that one > invocation for grep is done whenever maxarglen is hit (like if you used > xargs(1)), rather then one grep per file. > -- > Mel This list is amazing because everyday you learn something new. Thanks. a great day, v -- network warrior since 2005