题目:
编写一个的脚本,它包括以下内容
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