zoukankan      html  css  js  c++  java
  • linux课后作业1

    本实验6第一题:菜单驱动程序.

    随便进到某个目录,vim driver.sh

    把代码写进去。

    #!/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
           

    #!/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 " "}welcomeuntil [ $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        esacdoneecho "Thank you for your playing"exit 0       

  • 相关阅读:
    Where条件的in里面放太多数据导致很慢
    获取项目文件目录下的所有文件路径
    如何将数据转换成XML格式
    微信6.2开发笔记
    sql server 2008导出数据注意事项
    IIS7.5下404错误设置失效的问题
    采用ASP.NET IIS 注册工具 (Aspnet_regiis.exe)对web.config实行本地加密
    webkit自定义滚动条
    ueditor1_4_3-utf8-net使用笔记
    WebDev.WebServer40.exe已停止工作
  • 原文地址:https://www.cnblogs.com/double891/p/8974774.html
Copyright © 2011-2022 走看看