linux 文件日期转时间戳
1、获取文件的修改日期
[root@auc-test2 eccs]# stat eccs.log.232 File: "eccs.log.232" Size: 10485847 Blocks: 20488 IO Block: 4096 普通文件 Device: fd02h/64770d Inode: 1833867 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-11-30 11:24:57.585461975 +0800 Modify: 2014-11-30 11:24:57.598461975 +0800 Change: 2014-12-18 12:08:00.020797988 +0800 [root@auc-test2 eccs]# stat eccs.log.232 | grep Modify Modify: 2014-11-30 11:24:57.598461975 +0800 [root@auc-test2 eccs]# stat eccs.log.232 | grep Modify |awk '{print $2}' 2014-11-30 [root@auc-test2 eccs]# date +%s -d `stat eccs.log.232 | grep Modify |awk '{print $2}'` 1417276800
2、被比较的日期
[root@auc-test2 eccs]# date +%s -d 2019-1-1 1546272000
3、数字大小比较
# 命令中输入if # if command; then # commands # fi [root@auc-test2 eccs]# if((1546272000>1417276800));then echo "file modify date is earlier 2019-1-1" ; fi file modify date is earlier 2019-1-1
# 备注:if (); if条件后面有分号.
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20