Extract Zip or Rar files using the terminal on MAC OS X

16,798

Solution 1

You can usually use tar or zip for file compression. Something like

tar -x ~/somefile.zip

will extract the somefile.zip in your home folder to sub-folders defined in the zip.

tar -czf ~/mynewzip.zip ~/datafolder

will compress ~/datafolder to newzip.zip in your home folder. Make sure to read the man page for tar or zip for more details.

Solution 2

I guess following command will do the purpose:

unrar x <file_name>.rar

If unrar is not installed, you can use:

brew install unrar

Share:
16,798

Related videos on Youtube

S. Comu
Author by

S. Comu

Updated on September 18, 2022

Comments

  • S. Comu
    S. Comu over 1 year

    I have just started to work on a Mac terminal for a school work.

    My question is: which command do I have to write to extract files of a .zip or .rar file by using the terminal only? Is it the same command to open all types of compressed files?

    Thanks in advance.

    • user
      user almost 7 years
      I don't know what's available on a stock OS X installation, which is why I'm not making this an answer, but for zip files, have you tried unzip?
    • S. Comu
      S. Comu almost 7 years
      I have just tried to use this command and it's correct. Thanks!