Linux – How to stop tar from archiving the root path to files

linuxtarunix

When I run the following command:

tar cfvz backup.tar.gz /path/to/my/files/*

It gzips the entire path. So when I unzip the file, I have to go open 4 folders (path -> to -> my -> files) to get to the files I wanted to backup.

How do I make the files show in root of the gzipped file rather then the entire path?

Thanks in advance!

Best Answer

Try option -C:

tar cvzf backup.tar.gz -C /path/to/my/files/ .

Related Question