How can you extract only the target dir and not the complete dir tree?
compress
tar cf /var/www_bak/site.tar /var/www/site
extract
tar xf /var/www/site.tar -C /tmp
This will produce:
/tmp/var/www/site
How is it possible to avoid the whole dir tree to be created when the file is extracted?
What I want it to extract to:
/tmp/site
--strip-componentsflag if you're using busybox-embedded implementation oftar, though. – sylvainulg May 31 '18 at 12:45--transform='s/^.*\///'instead of strip-components. – CR. Sep 14 '22 at 21:07tar,--strip-components=2would only strip the leading slash and the first dir. To remove all of it, you'll need--strip-components=3. – emk2203 Dec 11 '22 at 22:32