]> git.armaanb.net Git - bin.git/blob - src/ex
first major commit
[bin.git] / src / ex
1 # General purpose extraction function, from Ubuntu bashrc
2 #!/usr/bin/env sh
3
4 ex() {
5   if [ -f $1 ] ; then
6     case $1 in
7       *.tar.bz2)   tar xjf $1   ;;
8       *.tar.gz)    tar xzf $1   ;;
9       *.bz2)       bunzip2 $1   ;;
10       *.rar)       unrar x $1   ;;
11       *.gz)        gunzip $1    ;;
12       *.tar)       tar xf $1    ;;
13       *.tbz2)      tar xjf $1   ;;
14       *.tgz)       tar xzf $1   ;;
15       *.zip)       unzip $1     ;;
16       *.Z)         uncompress $1;;
17       *.7z)        7z x $1      ;;
18       *.deb)       ar x $1      ;;
19       *.tar.xz)    tar xf $1    ;;
20       *.tar.zst)   unzstd $1    ;;      
21       *)           echo ''$1' cannot be extracted via ex()' ;;
22     esac
23   else
24     echo ''$1' is not a valid file'
25   fi
26 }
27