2. 只有當user輸入y/Y時,才會將檔案刪除。
#!/bin/bash
select VAR in a1 a2 a3 a4 a5 exit
do
case $VAR in
a1) read -p "Delete a1? (y/Y/n/N)" FLAG
if [ $FLAG = y -o $FLAG = Y ]; then
rm -f ./a1
fi;;
a2) read -p "Delete a2? (y/Y/n/N)" FLAG
if [ $FLAG = y -o $FLAG = Y ]; then
rm -f ./a2
fi;;
a3) read -p "Delete a3? (y/Y/n/N)" FLAG
if [ $FLAG = y -o $FLAG = Y ]; then
rm -f ./a3
fi;;
a4) read -p "Delete a4? (y/Y/n/N)" FLAG
if [ $FLAG = y -o $FLAG = Y ]; then
rm -f ./a4
fi;;
a5) read -p "Delete a5? (y/Y/n/N)" FLAG
if [ $FLAG = y -o $FLAG = Y ]; then
rm -f ./a5
fi;;
exit) exit;;
esac
done
No comments:
Post a Comment