configfiles/scripts/extract.sh

32 lines
589 B
Bash
Raw Normal View History

2015-10-06 08:00:57 +02:00
#!/bin/bash
extract_targz() { tar -xzvf "$1" }
extract_tarbz() { tar -xjvf "$1" }
extract_tarxz() { tar -xJvf "$1" }
extract_rar() { unrar x "$1" }
extract_zip() { unzip "$1" }
extractfile() {
case "$1" in
*.tar.gz|*.tgz)
extract_targz "$1"
;;
*.tar.bz)
extract_tarbz "$1"
;;
*.tar.xz)
extract_tarxz "$1"
;;
*.rar)
extract_rar "$1"
;;
*.zip)
extract_zip "$1"
;;
esac
}
for file in $@; do
extractfile "$file";
done