It depends on your version of tar
If you have the version that supports member transforms (--transform or --xform) then you can simply do
tar -c --transform=s/A/B/ A | gzip -9 > B.tar.gz
the | gzip -9 >B.tar.gz can be avoided if your tar supports the -z option
tar -zcvf B.tar.gz --transform=s/A/B/ A
If your version of tar doesn't support --transform then you will have to just copy the file first eg
cp A B && tar -zcvf B.tar.gz B
However if you are only compressing one file why not skip the tar part all together and just do
cat A | gzip -9 > B.gz
why would you like to pipe
cp A B
? – Dor – 2011-08-05T11:30:22.8701rename is
mv
. – Karoly Horvath – 2011-08-05T11:44:45.8373Please explain why you would like to copy
A
toB
first. – speakr – 2012-06-21T10:23:34.680