tar with -C and wildcard

From: tsh@mrc-lmb.cam.ac.uk
Date: Mon Apr 14 2003 - 06:10:19 EDT


TU64 5.1 PK5

Good morning all,
We have a curious problem with tar - I cant believe no-one has
tried this before, but also cant see what we may be doing wrong.

The following command fails instantly (no tape motion) with 'No Match'
error:

tar cvf $tape -C /somedirectory file*

but works of we cd to /somedirectory and then just

tar cvf $tape file*

e.g. (using /dev/null for testing)

%tar cvf /dev/null -C /ss1/tsh bootnet*
tar: No match.

But:
% tar -cvf /dev/null -C /ss1/tsh bootnet.img_6.2 bootnet.img_7.0
a bootnet.img_6.2 2880 Blocks
a bootnet.img_7.0 2880 Blocks

And:
%cd /ss1/tsh
%tar -cvf /dev/null bootnet*
a bootnet.img_6.2 2880 Blocks
a bootnet.img_7.0 2880 Blocks

Furthermore, if I am cd'd to directory A, which has files junk* in it,
then type

tar cvf $tape -C /someOtherDirectory junk*
or
tar cvf $tape -C /someOtherDirectory ./junk*

tar complains:
tar: junk : No such file or directory
tar: junk.bak : No such file or directory
tar: junk.c : No such file or directory
tar: junk.dialup : No such file or directory
tar: junk.ps : No such file or directory
tar: junkjunk : No such file or directory
tar: junkkk : No such file or directory
tar: junkz : No such file or directory

which are the names of files in directory A, not those in someOtherDirectory.

Escaping the * with \* simply makes it search for a filename with a * as
part of the name. I cant believe we havent done things like this before,
the only thing I can think of is the we upgraded to PK5 a couple of
months ago, but THE SAME THING HAPPENS WITH (an old) GNUTAR!

What am I doing wrong? Please put me out of my misery!

Cheers,
Terry.



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:15 EDT