[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A silly question about tar



On Thu, Mar 15, 2007 at 02:59:01 -0500, Adam Porter wrote:
> I've read the man page, googled this list and the rest of the Net, but I
> still can't figure out why this doesn't work:
> 
> $ tar xjf *.tar.bz2
> tar: beryl-core-0.2.0.tar.bz2: Not found in archive
> tar: beryl-manager-0.2.0.tar.bz2: Not found in archive
> tar: beryl-plugins-0.2.0.tar.bz2: Not found in archive
> tar: beryl-plugins-unsupported-0.2.0.tar.bz2: Not found in archive
> tar: beryl-settings-0.2.0.tar.bz2: Not found in archive
> tar: beryl-settings-bindings-0.2.0.tar.bz2: Not found in archive
> tar: beryl-settings-simple-0.2.0.tar.bz2: Not found in archive
> tar: emerald-0.2.0.tar.bz2: Not found in archive
> tar: emerald-themes-0.2.0.tar.bz2: Not found in archive
> tar: heliodor-0.2.0.tar.bz2: Not found in archive
> tar: Error exit delayed from previous errors
> 
> Not only did it completely fail, but it skipped the first file in the
> directory, aquamarine-0.2.0.tar.bz2.  But if I run the same command on a
> single file instead of a wildcard, it works fine.
> 
> Am I doing something wrong?  Why can't tar handle a wildcard list like that?

The wildcard (glob pattern) will be expanded to all the *.tar.bz2
filenames in one line, separated by spaces. This is fed as the argument
to tar. It looks like the "extract" action interprets the first filename
as the archive and the rest as files which should be extracted from that
archive. Of course it can then not find these names in the first archive
and fails.

I think what you want to do can be achieved like this:

for NAME in *.tar.bz2; do tar xjf $NAME; done

(This is a general bash trick. I did not test it for this specific
 case.)

-- 
Regards,
          Florian



Reply to: