Files
lnx-arch/dots/bin/extract.sh
committer@tuxwarrior 2154224899 / .bashrc cleanup
2025-04-12 11:49:58 -05:00

48 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# klevstul :: 24.06
this_file_name=`basename "$0"`
if [ $# -lt 1 ]; then
echo "error: path to file is missing."
echo "usage: '$this_file_name [path_to_file]'"
exit 1
fi
input_file=$1
if [ -f "${input_file}" ] ; then
case "$input_file" in
*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$input_file";;
*.tar.gz|*.tgz) tar xzvf "$input_file";;
*.tar.xz|*.txz) tar xJvf "$input_file";;
*.zip) unzip "$input_file";;
*.rar) unrar x "$input_file";;
*.7z) 7z x "$input_file";;
esac
fi
# # ex - archive extractor
# # usage: ex <file>
#ex ()
#{
# if [ -f $1 ] ; then
# case $1 in
# *.tar.bz2) tar xjf $1 ;;
# *.tar.gz) tar xzf $1 ;;
# *.bz2) bunzip2 $1 ;;
# *.rar) unrar x $1 ;;
# *.gz) gunzip $1 ;;
# *.tar) tar xf $1 ;;
# *.tbz2) tar xjf $1 ;;
# *.tgz) tar xzf $1 ;;
# *.zip) unzip $1 ;;
# *.Z) uncompress $1;;
# *.7z) 7z x $1 ;;
# *) echo "'$1' cannot be extracted via ex()" ;;
# esac
# else
# echo "'$1' is not a valid file"
# fi
#}