linux/unix自帶的的rm沒有確認(rèn)功能,自己寫了一個(gè)帶確認(rèn)功能的, 供自己娛樂
shell版 : /bin/sh -f echo "$1" echo -n "do you want to delete these files," $1 "?(y/n) .\b" read ANSWER echo "$ANSWER" if [ $ANSWER = y -o "$ANSWER" = "Y" ]; then rm $1 echo $1 "have been deleted" else echo "Action cancelled" fi c shell版 #! /bin/csh -f set files = $argv[1]; echo "The following files $files are going to be deleted."; echo -n "do you want to delete these files?(y/n) \b" set ANSWER = $< # stdin input if ( $ANSWER == y | $ANSWER == Y) then /bin/rm $files; echo "the files have been deleted"; endif |
|