shell中的时间日期获取
cat test5:
#!/bin/bash # using the backtick character testing=`date` echo "The date and time are:" $testing date=`date +%Y-%m-%d_%H-%M-%S` echo "The date are:" $date
添加可执行权限:chmod u+x test5
运行:./test5 结果如下:
The date and time are: Thu Jan 22 15:13:33 CST 2015 The date are: 2015-01-22_15-13-33