列出在特定日期未创建/修改的文件

时间:2019-09-19 11:03:35

标签: bash shell find

我要列出文件夹中除特定日期外的所有文件。

我尝试将find! -newermt搭配使用,但看起来现在可以正常工作了。

find /home/ubuntu/ -maxdepth 1  ! -newermt "2019-09-17" ! -newermt "2019-08-25" ! -newermt "2019-05-31" ! -newermt "2019-06-30" -type f

例如: 1.txt创建于2019-09-18

2.txt创建于2019-09-17

3.txt创建于2019-05-19

4.txt创建于2019-01-20

我想列出所有在2019-09-18、2019-01-20上未创建的文件

我希望结果应该是

2.txt创建于2019-09-17

3.txt创建于2019-05-19

1 个答案:

答案 0 :(得分:1)

find本质上是递归的,但您指定的最大深度为1。可以使用ls

ls -lah /home/ubuntu --time-style full-iso | awk '!/2019-01-20|2019-09-18/'

如果只需要文件名:

ls -lah /home/ubuntu --time-style full-iso | awk '!/2019-01-20|2019-09-18/' | awk 'BEGIN {ORS=""} {split($0,a," "); printf "%s\n",a[9]}'