109
18
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.
109
18
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.
172
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
what
-C
stands for? – AlikElzin-kilaka – 2015-01-28T15:56:14.4202@AlikElzin-kilaka From
man tar
-C, --directory DIR change to directory DIR – tachomi – 2015-01-28T16:31:57.1102
tar -xvjf foo.tar.bz2
for those who are looking for bz2 like me – vladkras – 2016-01-26T07:09:24.353You actually don't have to specify the compression format anymore with modern tar. I edited the answer so it will work with bz2, xz, and whatever else you want to throw at it. – Patches – 2016-10-08T23:59:33.710
thanks, how about
gzip -dc archive.tar.gz | tar -xf - -C /destination
? – alwbtc – 2011-10-19T13:12:39.873