SHARE
TWEET

Script for automatic extract archives in linux

Zeboton Jan 17th, 2012 1,047 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # put this into ~/.bashrc and relogin
  2. # use extract <path/file_name>
  3. extract () {
  4.   if [ -f $1 ] ; then
  5.     case $1 in
  6.       *.tar.bz2)   tar xvjf $1    ;;
  7.       *.tar.gz)    tar xvzf $1    ;;
  8.       *.tar.xz)    tar xvJf $1    ;;
  9.       *.bz2)       bunzip2 $1     ;;
  10.       *.rar)       unrar x $1     ;;
  11.       *.gz)        gunzip $1      ;;
  12.       *.tar)       tar xvf $1     ;;
  13.       *.tbz2)      tar xvjf $1    ;;
  14.       *.tgz)       tar xvzf $1    ;;
  15.       *.zip)       unzip $1       ;;
  16.       *.Z)         uncompress $1  ;;
  17.       *.7z)        7z x $1        ;;
  18.       *.xz)        unxz $1        ;;
  19.       *.exe)       cabextract $1  ;;
  20.       *)           echo "\`$1': unknown archive method" ;;
  21.    esac
  22.  else
  23.    echo "\`$1' file does not exist"
  24.   fi
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top