dotfiles/.local/bin/scripts/ex

25 lines
717 B
Bash
Executable File

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