Re: OT: the rm bug hit me again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joe Klemmer <klemmerj@xxxxxxxxxxx> 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@xxxxxxxxx


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux