bin: process all args in ex

This commit is contained in:
xerus2000 2021-02-24 12:16:28 +01:00
parent 531877c8db
commit 44f2ccca2a
1 changed files with 23 additions and 21 deletions

View File

@ -1,24 +1,26 @@
#!/bin/sh #!/bin/sh
# ex - archive extractor # ex - archive extractor
# usage: ex <file> # usage: ex <file>
if test -f $1 && test -r $1; then for arg do
case $1 in if test -r "$arg"; then
*.tar.bz2) tar xjf $1 ;; case "$arg" in
*.tar.gz) tar xzf $1 ;; *.tar.bz2) tar xjf "$arg" ;;
*.bz2) bunzip2 $1 ;; *.tar.gz) tar xzf "$arg" ;;
*.rar) unrar x $1 ;; *.bz2) bunzip2 "$arg" ;;
*.gz) gunzip $1 ;; *.rar) unrar x "$arg" ;;
*.tar) tar xf $1 ;; *.gz) gunzip "$arg" ;;
*.tbz2) tar xjf $1 ;; *.tar) tar xf "$arg" ;;
*.tgz) tar xzf $1 ;; *.tbz2) tar xjf "$arg" ;;
*.zip) unzip $1 ;; *.tgz) tar xzf "$arg" ;;
*.Z) uncompress $1;; *.zip) unzip "$arg" ;;
*.7z) 7z x $1 ;; *.Z) uncompress "$arg";;
*.deb) ar x $1 ;; *.7z) 7z x "$arg" ;;
*.tar.xz) tar xf $1 ;; *.deb) ar x "$arg" ;;
*.zst) unzstd $1 ;; *.tar.xz) tar xf "$arg" ;;
*) echo "'$1' cannot be extracted via ex()" ;; *.zst) unzstd "$arg" ;;
esac *) echo "'$arg' cannot be extracted by ex" ;;
else esac
echo "'$1' is not a readable file" else
fi echo "'$1' is not a readable file"
fi
done