编写一个脚本,该脚本可以判断当前用户是否为root。
[root@centos-jifu-vm ~]# cat ifroot.sh
#!/bin/bash
if [ "`echo $USER`" == root ]
then
echo "The current logining user is root"
else
echo "No, it is not root account"
fi
编写一个脚本,该脚本可以判断今天是否为休息日。
[root@centos-jifu-vm ~]# cat ifweeklyDay.sh
#!/bin/bash
#This is shell script for judge day is or not weekly day
#Author is allan
if [ `date +%w` -eq 0 ] || [ `date +%w` -eq 6 ] #date +%w 取值范围0-6 0指的是sunday
then
echo "Today is a weekly rest day"
else
echo "Today is a workday"
fi