Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix Untar a File Into a Directory

Tags:

unix

tar

I am trying to decompress a tar (.TGZ) file, but want to decompress it into a new directory called newdir.

The command I am using to decompress is: tar –xzf filename.tgz

How can I expand that to decompress it into newdir?

like image 961
Dustin Cook Avatar asked Feb 07 '14 09:02

Dustin Cook


1 Answers

Add the -C option (or --directory, it is the same):

tar –xzf filename.tgz -C /target/directory

From man tar:

-C, --directory DIR

change to directory DIR

like image 180
fedorqui 'SO stop harming' Avatar answered Oct 11 '22 23:10

fedorqui 'SO stop harming'