shell腳本,編寫1個彈出式菜單的shell程序並實現其簡單的菜單功能。


 

[root@localhost wyb]# cat zonghe.sh 
#!/bin/bash
#zonghe
usage(){
case $choice in
1)
read -p "please input the old file and new file : " old_file new_file
cp -r $old_file $new_file
if [ $? -eq 0 ];then
    echo "success!" >&2
fi    
     sleep 2
;;


2)
read -p "please input the file and newname : " file newname
mv $file $newname
if [ $? -eq 0 ] ;then
    echo "success!" >&2
fi    
sleep 2
;;


3)
read -p "please input the file or dir you wanna del : " filename
rm -rf $filename
if [ $? -eq 0 ];then
    echo "success!" >&2
fi    
sleep 2
;;


4)
read -p "please input the file you wanna find : " file
find / -name $file
if [ $? -eq 0 ];then
    echo "success!" >&2
fi
sleep 2    
;;

5)
exit 0
;;

*)
;;




esac

}


while :

do

cat<<EOF
 *************************************
*                MENU                  *

*   1.copy                 2.rename    *

*   3.remove               4.find      *

*                 5.exit              *


 *************************************
EOF
 

read -p "please enter your choice : " choice

usage

done

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM