Hello, On Mon, 12 Oct 2009, Dean Hilkewich wrote:
Anders Johansson wrote:
Hm, ok, something like this then
for clientdir in /backup/*; do cd $clientdir for daydir in $clientdir/*; do rarfile=$daydir/*.rar if [ ! -e $rarfile ]; then rarfile=$daydir/*.r01 fi
if ! test -e $rarfile; then echo "cannot find rarfile in $clientdir" >&2 continue; ### or exit? Depends what you want fi
unrar x $rarfile [ $? -eq 0 ] && rm -rf $daydir
Why the 'test'? And 'x' is the wrong command (fullpath, you want current dir, it might make no difference here though, that depends on how the rar was packed). And 'rar' is more robust, so one should prefer that over 'unrar' if rar is installed (which I assume). rar e "$rarfile" && rm -rf "$daydir" I'm not that sure on what conditions rar exits with a status != 0, so one might want to test / read up on that before really running that 'rm -rf'. That affects both variants.
done done
HTH, -dnh -- Who stole my tagline? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org