Reputation: 1565
$ tar -zcvf archive/test.tar.gz files
will give me as below:
files/
files/1
files/2
files/3
--
$ tar -zcvf archive/test.tar.gz -C files .
will give me as below :
./
./1
./2
./3
I am not able to figure out the right tar command for an output as below .
1
2
3
Upvotes: 0
Views: 429
Reputation: 94869
You use the --transform
option, which takes a sed expression.
--transform="s/^\.\///"
should have the desired effect.
Edit Oops, looks like this will leave a leading './' entry in the tar archive, which is probably not desirable. using @paulsm's answer is probably simpler, but it may miss out on hidden files (files starting with .)
Upvotes: 1
Reputation: 121881
Personally, I'd just:
cd files
tar -zcvf /full-path/archive/test.tar.gz *
Upvotes: 0