jay_lltv

extract bash function

Jan 2nd, 2026
5,675
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.67 KB | Source Code | 0 0
  1. function extract () {
  2.   if [ -f $1 ] ; then
  3.     case $1 in
  4.       *.tar.bz2)   tar xjvf $1    ;;
  5.       *.tar.gz)    tar xzvf $1    ;;
  6.       *.tar.xz)    tar xvf $1    ;;
  7.       *.bz2)       bzip2 -d $1    ;;
  8.       *.rar)       unrar2dir $1    ;;
  9.       *.gz)        gunzip $1    ;;
  10.       *.tar)       tar xf $1    ;;
  11.       *.tbz2)      tar xjf $1    ;;
  12.       *.tgz)       tar xzf $1    ;;
  13.       *.zip)       unzip2dir $1     ;;
  14.       *.Z)         uncompress $1    ;;
  15.       *.7z)        7z x $1    ;;
  16.       *.ace)       unace x $1    ;;
  17.       *)           echo "'$1' cannot be extracted via extract()"   ;;
  18.     esac
  19.   else
  20.     echo "'$1' is not a valid file"
  21.   fi
  22. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment