dotfiles/.local/bin/scripts/ex

27 lines
779 B
Plaintext
Raw Normal View History

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