Unrar Files With Terminal 10

Terminal

Share
Unrar Files With Terminal

Hey

This post is very similar to a previous post I have done about unzipping files using Terminal. This time it is about unrar’ing files. Although this type of trick wont be used every single day for unraring files. Programs like stuffit can handle that, but this trick has one awesome feature which I will explain shortly. The first step of this trick is to download the binaries. Head over to the winrar site. Then using the following command copy it into the binary folders. These are system folders which enable you to run the unrar binary from any Terminal window.The first step is to change directory to where you downloaded and extracted the files and then type the following.

sudo mv unrar /usr/bin

or

sudo mv unrar /usr/local/bin

Either will work for using the binary. I think the second command is used if you want to use it only for your self.

The next step is to invoke the binary. Its a bit complicated. The first step as always is to change directory to the folder you .rar files are in. You could type the whole file path although I find it is easier to change directory first. Simply type the following to unrar the files you want.

unrar e file.part1.rar

You must make sure the “e” is present that tells the program to extract your files.

Probably one of the best features of this program is to extract broken archives. Broken archives are archives where you have only one (or more) of the complete set. For example if you haven’t downloaded the complete set but want to see the contents. If you try to extract these files normally, it will give an error saying incomplete archive. One simple addition to the command line and you can extract them normally. Simply type.

unrar e -kb file.part1.rar

The kb part will tell the program to keep broken files. It may give an error but the extracted file will still exist. You can view and use these files in Finder as normal. Probably one of the best tips I have found in a long while and would have saved my lots of bandwidth and time with archives I don’t need.

There are a lots more options which you can use. Normally you would use man and then unrar, to view the manual page.. This doesn’t for this program just simply type:

unrar

To get all of the help messages. This will also show you the syntax and any options associated.

This is a simple trick, which is only good for the broken file command. Still useful even if you don’t use it. You may never know when such as tip may come in handy.

If you want to take your skills with Terminal a bit further I recommend you check out the Terminal Category on this site. If you fancy reading a book there is a couple on Amazon that I regularly see mentioned and recommend, O’reilly Unix Geeks and Unix Under the Hood both are designed for Mac OS X and take Terminal further.


If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

Where To Next?

  • Subscribe To Mac Tricks And Tips