Unix tar: do not preserve full pathnames

This is ugly... but it works...

I had this same problem but with multiple folders, I just wanted to flat every files out. You can use the option "transform" to pass a sed expression and... it works as expected.

this is the expression:

's/.*\///g' (delete everything before '/')

This is the final command:

tar --transform 's/.*\///g' -zcvf tarballName.tgz */*/*.info

Use -C to specify the directory from which the files look like you want, and then specify the files as seen from that directory:

tar -cvzf test.tar.gz -C /home/path test

multi-directory example

tar cvzf my.tar.gz example.zip -C dir1 files_under_dir1 -C dir2 files_under_dir2

the files under dir 1/2 should not have path.

Tags:

Unix

Shell

Tar