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       

  • 相关阅读:
    ImageMagick出错/undefined in findresource
    只对目录更改权限的办法(xarg)
    关于linux下php环境
    php 上传大文件
    做下载系统时的一些HTML文件头
    POJ 1694 An Old Stone Game ★(排序+树+递归)
    POJ 1991 Turning in Homework ★(区间DP)
    POJ 2452 Sticks Problem ★ (单调栈+RMQ)
    HDU 2069 Coin Change (母函数)
    HDU 2069 Coin Change (母函数)
  • 原文地址:https://www.cnblogs.com/double891/p/8974774.html
Copyright © 2011-2022 走看看