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