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       

  • 相关阅读:
    test!
    Visual Studio 中的单元测试 UNIT TEST
    Jquery结合div+css实现文字间断停顿向上滚动效果
    asp.net中使用HttpWebRequest发送上传文件
    分享一个可以灵活控制的实现Javascript滚动效果的程序
    VeryCodes.Log让日志记录和读取变的更简单
    实现MyXLS设置行高的功能
    设计模式学习笔记建造者模式
    设计模式学习笔记原型模式
    设计模式学习笔记模板方法
  • 原文地址:https://www.cnblogs.com/double891/p/8974774.html
Copyright © 2011-2022 走看看