zoukankan      html  css  js  c++  java
  • 实验6 shell程序设计一(1)

    设计如下一个菜单驱动程序

    Use one of the following options:
    P:To display current directory
    S:To display the name of running file
    D:To display today's date and present time (要求显示为:2017-04-26 05:45:12) 
    L:To see the list of files in your present working directory
    W:To see who is logged in
    Q:To quit this program
    Enter your option and hit:
    菜单程序将根据用户输入的选择项给出相应信息。要求对用户的输入忽略大小写,对于无效选项的输入给出相应提示。要求使用case语句实现以上功能,输入相应的字母后应该执行相应的命令完成每项功能,如输入P或p,就执行pwd命令。
     
    #!/bin/bash
    
    function welcome()
    {
        echo -e "
    "
        echo "Use one of the following options:"
        echo "P: To display current derectory "
        echo "S: To display the name of running file"
        echo "D: To display today's date and present time"
        echo "L: To see the listing of files in your present working directory"
        echo "W: To see who is logged in"
        echo "Q: To quit this program"
        echo -n    "Enter your option and hit:"
        read a
        echo -e "
    "
    }
    welcome
    until [ $a = q -o $a = Q ];
    do
        case "$a" in
        p|P)
        pwd
        welcome
        ;;
        s|S)
        echo "The running file is $0"
        welcome
        ;;
        d|D)
        date
        welcome
        ;;
        l|L)
        ls -a
        welcome
        ;;
        w|W)
        who
        welcome
        ;;
        *)
        echo -n "Sorry,your option is wrong,please enter your option again"
        echo -e "
    "
        read a
        esac
    done
    echo "Thank you for your playing"
    exit 0
     
     
     
     
  • 相关阅读:
    关于python3.x语法
    linux简单的安全防护
    hydra(爆破神器)
    扫描Linux服务器查找恶意软件和rootkit的一款工具
    chm 已取消到该网页的导航,打不开!
    android:activity知识点
    C# Mutex对象的使用
    惯性质量与引力质量的联系
    c# timer使用
    weiFenLuo.winFormsUI.Docking.dll学习
  • 原文地址:https://www.cnblogs.com/double891/p/9005593.html
Copyright © 2011-2022 走看看