[ale] Bash question: | in find

Geoffrey esoteric at 3times25.net
Fri Jan 24 13:20:24 EST 2003


Joe wrote:
> Geoffrey <esoteric at 3times25.net> writes:
> 
> 
>>Joe wrote:
>>
>>
>>>Why weird? We're telling echo not to put any newlines anywhere, so
>>>unless and until "tar" spits out a result that doesn't go to stderr,
>>>we get a huge list of files, all on one line.  The tar command isn't
>>>going to emit a newline to stdout when it doesn't find the file we're
>>>asking for, right?  So the "grep" spits out that line, and the last
>>>file listed is the one containing the string.  Perhaps ksh emits a
>>>newline after the tar command for some reason, and bash doesn't?
>>
>>tar produces a newline after each entry it prints, thus I don't
>>understand how it is that all the listed files coming from tar are
>>suddenly listed on one file.
> 
> 
> But this list isn't coming from tar; it's coming from find+echo.  Only
> if tar finds a file that matches the given pattern in one of the list
> or archives produced by find will it produce any non-error output.

Light goes on (unfortunately, only for a short time...)

Gotcha, you're referring to the filenames of the tar files, not the 
files located in the tar files.

Easiest solution is stick a echo following the tar command, then you end 
up with each tar file listed on separate lines when no matches are made 
against the contents of the tar file.

It's too bad tar's return value is not useful.  I've noted that tar 
against a non-existent file still returns 0.  Otherwise you could do 
something like:

tar -tvzf tarball.tgz '*fileIwant*' && print $fn


-- 
Until later: Geoffrey		esoteric at 3times25.net

The latest, most widespread virus?  Microsoft end user agreement.
Think about it...

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list