Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 May 2009 10:39:06 -0700
From:      Walt Pawley <walt@wump.org>
To:        Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>, Polytropon <freebsd@edvax.de>
Cc:        Zbigniew Szalbot <z.szalbot@lcwords.com>, freebsd-questions@freebsd.org
Subject:   Re: find and searching for specific expression in files
Message-ID:  <p06240823c6471d0dd353@[10.0.0.10]>
In-Reply-To: <alpine.BSF.2.00.0905301843550.19030@wojtek.tensor.gdynia.pl>
References:  <dd6b168d2af9ddbcfc52e5c0397e4d6a.squirrel@relay.lc-words.com> <20090530183239.a6755d97.freebsd@edvax.de> <alpine.BSF.2.00.0905301843550.19030@wojtek.tensor.gdynia.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
At 6:44 PM +0200 5/30/09, Wojciech Puchar wrote:
>> the famous back-tics.
>>
>> 	% grep "expression" `find /path/to/files/ -mtime -2 -print`
>>
>> Of course, there are surely easier, faster and better means,
>> but from this one, I know it just works. :-) Furthermore, I
>
>unless filelist exceed max lenght of arguments and unfortunately it
>happens often

I use bash as my default shell and have become rather enamored
with the construct

<make-a-list> | while read x; do <pretty-much-whatever> "$x"; done

which should get around the list length limitations and
provides for doing "extras" between the "do" and the "done".
Specifically:

find /path/to/files/ -mtime -2 -print | \
while read x; do grep "expression" "$x"; done
-- 

Walter M. Pawley <walt@wump.org>
Wump Research & Company
676 River Bend Road, Roseburg, OR 97471
         541-672-8975



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p06240823c6471d0dd353>