Advertisement
metalx1000

Script to Extract Compressed files

Feb 16th, 2018
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.51 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ -f $1 ] ; then
  4. case $1 in
  5.   *.tar.bz2)   tar xvjf $1    ;;
  6.   *.tar.gz)    tar xvzf $1    ;;
  7.   *.bz2)       bunzip2 $1     ;;
  8.   *.rar)       unrar x $1     ;;
  9.   *.gz)        gunzip $1      ;;
  10.   *.tar)       tar xvf $1     ;;
  11.   *.tbz2)      tar xvjf $1    ;;
  12.   *.tgz)       tar xvzf $1    ;;
  13.   *.zip)       unzip $1       ;;
  14.   *.Z)         uncompress $1  ;;
  15.   *.7z)        7z x $1        ;;
  16.   *)           echo "Unable to extract '$1'" ;;
  17. esac
  18. else
  19.   echo "'$1' is not a valid file"
  20. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement