tar with -C and wildcard

From: <tsh_at_mrc-lmb.cam.ac.uk>
Date: Mon, 14 Apr 2003 11:10:19 +0100 (BST)

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.
Received on Mon Apr 14 2003 - 10:11:26 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:44 NZDT