Created
June 25, 2017 19:09
-
-
Save amalmurali47/85bf80e7df4939070d10a7d29d5f2d60 to your computer and use it in GitHub Desktop.
Extract Anything
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extract() { | |
filename=$1 | |
if [ -f $filename ]; then | |
case $filename in | |
*.tar.xz) tar xvfJ $filename ;; | |
*.tar.gz) tar --gzip -xvf $filename ;; | |
*.tar.bz2) tar --bzip2 -xvf $filename ;; | |
*.tar) tar -xvf $filename ;; | |
*.tgz) tar --gzip -xvf $filename ;; | |
*.tbz2) tar --bzip2 -xvf $filename ;; | |
*.bz2) bunzip2 $filename ;; | |
*.7z) 7za x $filename ;; | |
*.Z) uncompress --keep $filename ;; | |
*.zip) unzip $filename -d ${filename%.*} ;; | |
*.rar) unrar x $filename ;; | |
*.jar) jar xf $filename ;; | |
*) echo "'$filename' not supported extension" ;; | |
esac | |
else | |
echo "'$filename' not a file." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment