OT: the rm bug hit me again
Donald Arseneau
asnd at triumf.ca
Sat Oct 28 03:35:23 UTC 2006
Joe Klemmer <klemmerj at webtrek.com> writes:
> I alomst hate to admit it but the rm bug bit me for the second time
> # rm -fR mozilla *
Being On Topic: the propensity of distributions like Fedora to
alias rm='rm -i'
leads to hassles when it is not needed and a disasterous habit
of using rm -f.
I use this:
export RM_NUM_CONFIRM=11
function FRM_CONF ()
{
local rm_ok="y"
local rqual="-d --"
local q
for q do
case "$q" in
--)
break
;;
--recursive)
rqual="-RA --"
break
;;
--*)
;;
-*[rR]*)
rqual="-RA --"
break
;;
esac
done
local num_rm=$[$(ls 2>/dev/null $rqual $@ | wc -w)]
if [ "$num_rm" -ge "$RM_NUM_CONFIRM" ]
then
echo -n "Remove (approx) $num_rm files OK? "
read rm_ok
fi
if [ "z$rm_ok" = "zy" -o "z$rm_ok" = "zY" ]
then
\rm "$@"
fi
}
alias rm=FRM_CONF
Not perfect, but quite nice.
--
Donald Arseneau asnd at triumf.ca
More information about the users
mailing list