Maybe OT - Grepping the locate command
John McCabe-Dansted
gmatht at gmail.com
Wed Mar 3 14:43:18 GMT 2010
On Wed, Mar 3, 2010 at 10:11 PM, Kevin Hunter <hunteke at earlham.edu> wrote:
> At 6:36am -0500 Wed, 03 Mar 2010, donn wrote:
>> On 03/03/2010 13:08, John McCabe-Dansted wrote:
>>> so we need something a bit longer like. locate *.ods | while read f ;
>>> do unzip -p $f | grep BLAH> /dev/null && echo $f ; done
>>
>> Groovy. I added quotes to handle weird filenames:
>> locate *.ods | while read f; do unzip -p "$f" | grep -i "gas" >/dev/null
>> && echo "$f"; done
>
> Actually, even that can get you in to trouble. If you want to be
> robust, consider using a delimiter that *can't* be in the filename. For
> example, the NUL byte:
Could you demonstrate the problem? Using quotes seems to work fine on
files with "'s in the filename.
$ echo TTT > 'test"'
$ F='test"'
$ cat $F
TTT
$ cat "$F"
TTT
--
John C. McCabe-Dansted
More information about the sounder
mailing list