tar - Remove leading directory components on extraction
Solution 1:
You want to use the --strip-components=NUMBER
option of tar
:
--strip-components=NUMBER
strip NUMBER leading components from file names on extraction
Your command would be:
tar xfz /var/www/site.gz --strip-components=2 -C /tmp
Solution 2:
Why not use -C
option when creating:
$ tar cf /var/www/site.tar -C /var/www_bak/ site