简体   繁体   English

获取特定日期戳后进入UNIX文件夹的文件数

[英]Get the count of files coming in UNIX folder after certain datestamp

I want to get the count of files coming into UNIX directory after certain date stamp. 我想获取某些日期戳后进入UNIX目录的文件数。

eg I have a folder with the date 28062017 and files are copied to it in certain time. 例如,我有一个日期为28062017的文件夹,并且在特定时间内将文件复制到该文件夹​​。

I want to get the count of file coming from certain time. 我想获取特定时间的文件计数。 say

Jun 28 21:17 file 1
Jun 28 21:18 file 2
Jun 28 21:19 file 3
Jun 28 21:20 file 4
Jun 28 21:21 file 5
Jun 28 21:22 file 6
Jun 28 21:23 file 7
Jun 28 21:24 file 8

I want to have the count of files generated after Jun 28 21:21 . 我想拥有Jun 28 21:21之后生成的文件数。

Thanks 谢谢

You can use find using newermt (for modification time): find . -newermt "2017-01-03" -type f -ls | wc -l 您可以使用find使用newermt (用于修改时间): find . -newermt "2017-01-03" -type f -ls | wc -l find . -newermt "2017-01-03" -type f -ls | wc -l find . -newermt "2017-01-03" -type f -ls | wc -l and than count the number of lines. find . -newermt "2017-01-03" -type f -ls | wc -l然后计算行数。

For example: 例如:

herbert@projects:~/tmp/datetest$ touch -t 201701020100 a.txt
herbert@projects:~/tmp/datetest$ touch -t 201701030100 b.txt
herbert@projects:~/tmp/datetest$ touch -t 201701040100 c.txt
herbert@projects:~/tmp/datetest$ find . -newermt "2017-01-03" -type f -ls
 82353    0 -rw-r--r--   1 herbert  herbert         0 Jan  4 01:00 ./c.txt
 82352    0 -rw-r--r--   1 herbert  herbert         0 Jan  3 01:00 ./b.txt
herbert@projects:~/tmp/datetest$ find . -newermt "2017-01-03" -type f -ls | wc -l
2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM