Created
June 6, 2014 03:14
-
-
Save huzhifeng/0a42a538fee47b0abe65 to your computer and use it in GitHub Desktop.
Smart uncompress
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
#!/bin/bash | |
smart_uncompress() | |
{ | |
if [ $# -lt 1 ]; then | |
echo "At least one paramater required" | |
exit 1 | |
fi | |
ftype="$(file $1)" | |
case ${ftype} in | |
"$1: Zip archive"*) | |
unzip $1 ;; | |
"$1: gzip compressed"*) | |
tar -xzf $1 ;; | |
"$1: bzip2 compressed"*) | |
tar -xjf $1 ;; | |
*) | |
echo "File $1 can not be uncompressed with smartzip" ;; | |
esac | |
} | |
smart_uncompress $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment