显示7天前(后)的时间 for linux

find命令用法举例-LMLPHP

“find”的用法:

删除”/tmp”目录下,7天前的文件

find /tmp -name "*" -type f-mtime +7 -exec rm -rf {} \;

列出”/tmp”目录下,7天前的文件

find /tmp -name "*" -type f-mtime +7 -exec ls {} \;

列出从现在起往前24个小时之内修改过的文件

$ find /home/postgres/wmpay_archive_log/-name "*" -type f -mtime 0 -exec ls -l {} \;

列出前一天修改过的文件:

$ find /home/postgres/wmpay_archive_log/-name "*" -type f -mmin -$(expr `date +%H` \* 60 + `date +%M` + 1440\* 1) -a -mmin +$(expr `date +%H` \* 60 + `date +%M`) -exec ls -l {} \;

复制前一天的文件到新的目录中

$ find /home/postgres/wmpay_archive_log/-name "*" -type f -mmin -$(expr `date +%H` \* 60 + `date +%M` + 1440\* 1) -a -mmin +$(expr `date +%H` \* 60 + `date +%M`) -exec cp {}/home/postgres/script/wmpay_archive_log_bak \;

05-07 13:21
查看更多