dotfiles/.local/bin/scripts/ex

25 lines
717 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" ;;
2021-09-20 06:57:20 +00:00
*.tar.*|*.tar) tar --extract --file "$arg";;
2021-02-24 11:16:28 +00:00
*.bz2) bunzip2 "$arg" ;;
*.rar) unrar x "$arg" ;;
*.gz) gunzip "$arg" ;;
*.tbz2) tar xjf "$arg" ;;
*.tgz) tar xzf "$arg" ;;
2021-05-07 10:31:14 +00:00
*.zip|*.jar) unzip "$arg" ;;
2021-02-24 11:16:28 +00:00
*.Z) uncompress "$arg";;
*.7z) 7z x "$arg" ;;
*.deb) ar x "$arg" ;;
2021-07-29 14:02:20 +00:00
*.zst) unzstd "$arg" ;;
2021-02-24 11:16:28 +00:00
*) echo "'$arg' cannot be extracted by ex" ;;
esac
else
echo "'$1' is not a readable file"
fi
done