zoukankan      html  css  js  c++  java
  • shell编程题(十四)

    题目:

    编写一个的脚本,它包括以下内容

    a) 包含一段注释,列出您的姓名、脚本的名称和编写这个脚本的目的。

    b) 问候用户。

    c) 显示日期和时间。

    d) 显示这个月的日历。

    e) 显示您的机器名。

    f) 显示当前这个操作系统的名称和版本。

    g) 显示父目录中的所有文件的列表。

    h) 显示root正在运行的所有进程。

    i) 显示变量TERM、PATH和HOME的值。

    j) 显示磁盘使用情况。

    k) 用id命令打印出您的组ID。

    m) 跟用户说“Good bye”

    答案:

    #!/bin/bash
    
    user=`whoami`
    
    case $user in
        root)
            echo "hello robot";;
        ubuntu)
            echo "hello ubuntu";;
        *)
            echo "hello $user, welcome"
    esac
    
    echo "date: `date`"
    echo "calendar: `cal`"
    echo "name: `uname -n`"
    echo "name of operation and version: `uname -s; uname -r`"
    echo "all file list of parent menu: `ls ../`"
    echo "all process running of root: `ps -u root`"
    echo "the value of TERM: `$TERM`"
    echo "the value of PATH: `$PATH`"
    echo "the value of HOME: `$HOME`"
    echo "disk usage: `df`"
    echo "print group id: `id -g`"
    echo "Good bye~"
    exit 0
  • 相关阅读:
    Mybatis和Hibernate
    SpringMVC运行原理
    HTML中class属性里有多个属性值
    json对象(增加数据)
    Ajax请求
    <url-pattern>里的/和/*
    mysql忘记密码
    Eclipse无法正常连接mysql8.0.20
    a+1和&a+1
    可重入函数与不可重入函数
  • 原文地址:https://www.cnblogs.com/wanghao-boke/p/12149018.html
Copyright © 2011-2022 走看看