我是一只小小鸟
全部博文(184)
分类: LINUX
2014-03-26 14:32:18
date.sh:
点击(此处)折叠或打开
#!/bin/bash
D=$(date "+%m--%d--%Y %H:%M:%S")
DATE=$(date "+%Y--%m--%d")
TIME=$(date "+%H:%M:%S")
YES_DATE=$(date -d yesterday)
TODAY_DATE=$(date -d today)
TOM_DATE=$(date -d tomorrow)
NOW_DATE=$(date -d now)
echo "------$D------"
echo "The date is $DATE"
echo "The time is $TIME"
echo "Yesterday is $YES_DATE"
echo "Today is $TODAY_DATE"
echo "Tomorrow is $TOM_DATE"
echo "Now is $NOW_DATE"
exit 0
#end
[root@test7 scripts]# sh date.sh
------03--26--2014 14:29:33------
The date is 2014--03--26
The time is 14:29:33
Yesterday is Tue Mar 25 14:29:33 CST 2014
Today is Wed Mar 26 14:29:33 CST 2014
Tomorrow is Thu Mar 27 14:29:33 CST 2014
Now is Wed Mar 26 14:29:33 CST 2014