Talvez o seguinte script seja melhor:
Note: Pay attention to
rm
command! Useecho "rm -rf $sub_folder"
for testing.
#!/bin/bash
if [ $# -ne 1 ];then
echo "Usage: 'basename $0' DIRECTORY"
exit 1
fi
for sub_folder in 'find $@ -type d -atime +7 2>/dev/null' ; do
rm -rf $sub_folder
done
exit 0