Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract tar file in Mac terminal

Tags:

terminal

As titled. I want to use some command, like for .zip files I can say

unzip myfiles.zip -d mydirectory

But is there a thing for .tar file on Mac as well?

like image 621
nekodesu Avatar asked Aug 04 '18 20:08

nekodesu


People also ask

Can you open a tar file on a Mac?

On a Mac, just double-click the TAR, TGZ, or TAR. GZ file to unpack it. On Windows, you'll need free software like 7-Zip to untar files. If you're using Linux or the Mac Terminal app, use "tar -xvf" for TAR files, or "tar -xvzf" for files ending in TGZ or TAR.


1 Answers

Yes, you can run:

tar -xvf myfile.tar 

For .tar.gz, you can run:

tar -xzvf myfile.tar.gz 

If you want to extract to any directory other than your cwd, use -C. e.g:

tar -xvf myfile.tar -C somedirectory 

I suggest you read the man page for tar if you wish to do anything further:

man tar 
like image 188
yuikonnu Avatar answered Oct 01 '22 03:10

yuikonnu