Skip to content

Instantly share code, notes, and snippets.

@mischw
Created September 8, 2021 01:35
Show Gist options
  • Save mischw/ad6ba8d264b449d113a485c2879fbc39 to your computer and use it in GitHub Desktop.
Save mischw/ad6ba8d264b449d113a485c2879fbc39 to your computer and use it in GitHub Desktop.
ex () {
for arg in $@ ; do
if [ -f $arg ] ; then
case $arg in
*.tar.bz2) tar xjf $arg ;;
*.tar.gz) tar xzf $arg ;;
*.ova) tar xvf $arg ;; # Then to qcow2: qemu-img convert -O qcow2 MyAppliance-disk1.vmdk MyAppliance.qcow2
*.tar) tar xf $arg ;;
*.tbz2) tar xjf $arg ;;
*.tgz) tar xzf $arg ;;
*.bz2) bunzip2 $arg ;;
*.gz) gunzip $arg ;;
*.zip) unzip $arg ;;
*.Z) uncompress $arg ;;
*.rar) unrar x $arg ;; # 'unrar' must be installed
*.jar) jar -xvf $arg ;; # 'jdk' must be installed
*.7z) 7z x $arg ;;
*) echo "'$arg' cannot be extracted via ex()" ;;
esac
else
echo "'$arg' is not a valid file"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment