to work with this you have to install the apropriate packages for archives like tar, unrar, bunzip2, gunzip, unzip, uncompress and 7z
ex () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;