I want to unpack a .tar.gz file to a specific directory.
The archive file is in /root/Documents. I want to unzip it into /root/Desktop/folder. The folder structure in zipped file should be preserved in the destination directory.
I want to unpack a .tar.gz file to a specific directory.
The archive file is in /root/Documents. I want to unzip it into /root/Desktop/folder. The folder structure in zipped file should be preserved in the destination directory.
You have two choices:
cd /root/Desktop/folder
tar xf /root/Documents/file.tar.gz
or
tar xf file.tar.gz -C /root/Desktop/folder
gzip -dc archive.tar.gz | tar -xf - -C /destination? – alwbtc Oct 19 '11 at 13:12-Cstands for? – AlikElzin-kilaka Jan 28 '15 at 15:56man tar-C, --directory DIR change to directory DIR – tachomi Jan 28 '15 at 16:31tar -xvjf foo.tar.bz2for those who are looking for bz2 like me – vladkras Jan 26 '16 at 07:09tar -xf foobar-1.2.tgz -C /opt --one-top-level=foobarhttps://unix.stackexchange.com/a/478341/5164 – Patches Sep 14 '21 at 01:24