1.读取日期
Linux:~ # date
Mon Dec 17 03:16:53 EST 2018
2.格式日期并打印
Linux:~ # date "+%d %B %Y"
17 December 2018
3.设置日期时间
Linux:~ # date -s "16 Dec 2018 5:20:21"
Sun Dec 16 05:20:21 EST 2018
上述命令为设置系统日期为:2018年12月16日 5点20分21秒
4.查看命令运行时间
#!/bin/bash start=$(date +%s) echo "hellwo world" sleep 1s echo "after 1s" end=$(date +%s) difference=$((end - start)) echo Time Taken to execute commands is $difference seconds.
执行结果
5.生成延时50秒的脚本
1 #!bin/bash 2 echo Count: 3 tput sc #存储光标位置 4 5 #循环50s 6 for count in `seq 0 50` #循环生成数字 7 do 8 tput rc #恢复之前存储的光标位置 9 tput ed #清除从当前光标位置到行尾之间的所有内容 10 echo -n $count 11 sleep 1 12 done