find will show you the rm command it is ready to execute and ask you whether to run it or skip it for each selected file. Alternatively, you could use:
-exec rm -ri {} +
to have rm do the prompting and have find run rm fewer times.
---------- Post updated at 03:02 PM ---------- Previous update was at 03:00 PM ----------
Well I have about 25 more directories and with different -mtimes so I was going to make a menu so that we could go through all of them one at a time, verify visually before we delete them?
---------- Post updated at 03:03 PM ---------- Previous update was at 03:02 PM ----------
I also don't want them to ask Y or N for each file but for each dir.
ask() { # "Question to ask"
# Ask a question (y/n)
# Returns 0 for yes, 1 for no
read -n1 -p "$1 (y/n): " ANSWER
[ [yjso] = "$ANSWER" ] && return 0 || return 1
# Returns YES (0) for yes, si, oui, ja (first letters)
}
BASE=/some/dir
cd $BASE
for FOUND in $(find . -name);do ### might become ARG_MAX, but you said its only ~25
[ -d $FOUND ] && \
ask "Delete: $FOUND and all subdirectories?" && \
rm -fr $FOUND
done
Hth & gn8
Do on your own risk - untested too tired on windows...