Archive

Posts Tagged ‘extract’

Linux Extract Script

March 13th, 2009 No comments
CODE:
  1. The following function will decompress a wide range of compressed filetypes. Add the function to '~/.bashrc' and then run with the syntax 'extract MyCompressedFile'
  2.  
  3.  extract () {
  4.    if [ -f $1 ] ; then
  5.        case $1 in
  6.            *.tar.bz2)   tar xvjf $1    ;;
  7.            *.tar.gz)    tar xvzf $1    ;;
  8.            *.bz2)       bunzip2 $1     ;;
  9.            *.rar)       rar x $1       ;;
  10.            *.gz)        gunzip $1      ;;
  11.            *.tar)       tar xvf $1     ;;
  12.            *.tbz2)      tar xvjf $1    ;;
  13.            *.tgz)       tar xvzf $1    ;;
  14.            *.zip)       unzip $1       ;;
  15.            *.Z)         uncompress $1  ;;
  16.            *.7z)        7z x $1        ;;
  17.            *)           echo "don't know how to extract '$1'..." ;;
  18.        esac
  19.    else
  20.        echo "'$1' is not a valid file!"
  21.    fi
  22.  }

Categories: Linux Tags: , ,
17039 pages viewed, 0 today
11071 visits, 0 today
FireStats icon Powered by FireStats