Linux find files with timestamp

By | 2018 年 4 月 20 日
  1. Touch a tmp file with the timestamp as needed.

    $ touch -t '201801010700' /tmp/$$
    
  2. Find the files based on that timestamp:

    To find files with access time newer than the file:

    find . -anewer /tmp/$$ -type f | wc -l
    

    To find files with access time older than the file:

    find . ! -anewer /tmp/$$ -type f | wc -l
    

Then after the pipe | you can concat any post cmd on the selected files.
The -type f here is for select only regular files.

With | xargs anothercmd you can do more with this. It basically will call anothercmd selected_file for each file output by find.

发表评论

电子邮件地址不会被公开。 必填项已用*标注