#!/bin/ksh #This shellscript is ~/bin/rm, my own version of rm. #First argument can be an optional -i or -f. interactive=0 while [[ "$1" == -i || "$1" == -f ]] #two =s for string compare do if [[ "$1" == -i ]] then interactive=1 #one = to assign fi shift #move args left, subtract 1 from $#, p. 155 done for filename do if [[ $interactive -eq 1 ]] #-eq to compare two numbers then echo $0: remove $filename'? \c' #Hand 5, pp. 14, 21 for \c read answer if [[ "$answer" != y* ]] #Like -P* in Handout 7, p. 2. then continue #go back to top of "for": ksh(1) p. 39 fi fi mv $filename ~/.trash/${filename##*/}$$ done if [[ -t 2 && `ls ~/.trash | wc -l` -ge 20 ]] then echo $0: time to empty or compress the .trash 1>&2 fi exit 0