Skip to content

Instantly share code, notes, and snippets.

@xim
Created July 11, 2010 20:08
Show Gist options
  • Save xim/471782 to your computer and use it in GitHub Desktop.
Save xim/471782 to your computer and use it in GitHub Desktop.
Unrar recursively in bash, using evil™
#!/bin/bash -xv
# ^^ debug, feel free to remove...
# Enable evil expansion mode: +([0-9])
shopt -s extglob
do_unrar() {
rar x "$@"
}
recurse_rar() {
for path in "$@" ; do
if test -d "$path" ; then
recurse_rar "$path"/*
elif test -z "${path##*.part+([0-9]).rar}" ;then
test "${path##*.part*(0)1.rar}" || do_unrar "$path"
elif test -z "${path##*.rar}" ;then
do_unrar "$path"
fi
done
}
recurse_rar "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment