Simple untar function for your shell

Published at 01, December 2008, author art. Tags: shell, utils

This simple function will save you a few keystrokes each time, when you need to unpack some tar archive.

Here we are! It's easy and should work in bash and zsh.

function untar()
{
    [ `basename $1 .gz`  != $1 ] && tar -zxvf $1 && return 0
    [ `basename $1 .bz2` != $1 ] && tar -jxvf $1 && return 0
}

Comments

Subscribe on this post's comments

permalink

01, December 2008, Āudioslave ᵝ « ... » said:

you forgot about archive.tgz

permalink

01, December 2008, Āudioslave ᵝ « ... » said:

maybe something like

...
[ `basename $1 .tar.gz` != $1 ] || [ `basename $1 .tgz` != $1 ] && ...
...

permalink

01, December 2008, art said:

It is better to add another line to this function instead of this complex logic.

If you wish to leave comment, please, identify yourself and then come back to this page.