linux find命令用法
1、搜索某一时间段建立的文件:
find . -type f -newermt "2023-11-15 11:55:00" ! -newermt "2023-11-15 12:00:00"
-newerXY argument 表示搜索argument之后文件。X和Y可以下如下组合:
a The access time of the file reference
B The birth time of the file reference
c The inode status change time of reference
m The modification time of the file reference
t reference is interpreted directly as a time
搜索argument之前的文件可以使用! -newerXY
2、搜索到的文件直接对其进行某种操作:
find /etc_data/pass/send -maxdepth 1 -type d ! -newermt $(date -d 'now -4 days' '+%Y%m%d') -exec echo {}\/ \;
最后的\;是必须存在的,表示命令执行完毕。
-exec代表搜索到的文件要执行某一操作,其中{}代表搜索到的文件