zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    spring-boot 访问时,加与不加项目名分析
    关于文章
    随笔
    工作小结五
    《文章翻译》PCA&SVD
    工作小结四
    工作小结三
    从零开始实现SSD目标检测(pytorch)(一)
    工作小结二
    《论文翻译》 GIOU
  • 原文地址:https://www.cnblogs.com/wangyuebo/p/5818626.html
Copyright © 2011-2022 走看看