Extract (almost) any archive type

After getting tired of trying to remember “tar xvzf”, I wrote a little script for extracting almost any file type via the linux command-line. You can copy and paste this script into a text editor like gedit and save it to “/usr/local/bin” for convenience. I called mine “untar” since it doesn’t seem to be taken. Remember to `chmod +x ` so that you can execute it. You may need to `sudo apt-get install unrar` if you don’t already have it. I’m sure you can see how to add other file types from this example.

me=`basename $0`
if [ $# -eq 0 ]; then
    echo "usage: $me <files...>"
for file in $@; do
    bn=`basename $file`
    case $file in
            tar xvf $file;;
            tar xvzf $file;;
            tar xvjf $file;;
            unzip $file;;
            unrar x $file;;
            echo "$me: $bn: unkown filetype";;