- 論壇徽章:
- 0
|
Date 命令參數(shù)小技巧
LastUpdated:2006-03-27
By:Gman!
-for beginner:wink:
此參數(shù)可以用于日志處理和時(shí)間統(tǒng)計(jì);
由于Linux對(duì)man date -d 參數(shù)說的比較模糊,故舉例如下:
# -d, --date=STRING display time described by STRING, not `now'
For Linux
[root@Gman root]# date -d next-day +%Y%m%d
20060328
[root@Gman root]# date -d last-day +%Y%m%d
20060326
[root@Gman root]# date -d yesterday +%Y%m%d
20060326
[root@Gman root]# date -d tomorrow +%Y%m%d
20060328
[root@Gman root]# date -d last-month +%Y%m
200602
[root@Gman root]# date -d next-month +%Y%m
200604
[root@Gman root]# date -d next-year +%Y
2007
-------------
而FreeBSD則不同;舉例如下:
For FreeBSD
bash-2.05b# date -v -1d +%Y%m%d
20060326
bash-2.05b# date -v -1m +%Y%m%d
20060227
bash-2.05b# date -v -1y +%Y%m%d
20050327
FreeBSD 的man date很詳細(xì);我就不一一舉例了; |
|