我谷歌查找文档,并写了这个
find . -type f -depth 1 -Btime 1
但是,我不工作?我怎样才能完成这项工作?
-Btime 5
匹配五天前创建的文件(其中 4.1 向上舍入为 5,5.1 向上舍入为 6)。如果您指的是从现在到五天前创建的文件,请使用-Btime -5
.
find . -type f -Btime -5 # five days ago or newer
find . -type f -Btime 5 # five days ago
find . -type f -Btime +5 # five days ago or older
find . -type f -Btime +5 -Btime -10 # between five days ago and ten days ago
也-maxdepth 1
或-mindepth 1 -maxdepth 1
比 快-depth 1
。-depth 1
遍历目录树下的所有文件。
可以与-atime
、-Btime
、-ctime
和一起使用的格式在-mtime
下进行了描述-atime
:
-atime n[smhdw]
If no units are specified, this primary evaluates to true if the difference
between the file last access time and the time find was started, rounded up to
the next full 24-hour period, is n 24-hour periods.
If units are specified, this primary evaluates to true if the difference between
the file last access time and the time find was started is exactly n units. Pos-
sible time units are as follows:
s second
m minute (60 seconds)
h hour (60 minutes)
d day (24 hours)
w week (7 days)
Any number of units may be combined in one -atime argument, for example, ``-atime
-1h30m''. Units are probably only useful when used in conjunction with the + or
- modifier.
find . -type f -depth 1 -Btime -1
和“-”到定义的数字
您的帖子与此线程类似。无论如何,你可以有这样的命令。
find -newerct 'now -1 hour'
或者
BEFORE=$(( $(date '+%s') - 3600 )) ## In seconds = 1 hour.
find -type f -printf '%C@ %p\n' | while read -r TS FILE; do TS=${TS%.*}; [[ TS -ge BEFORE ]] && echo "$FILE"; done
如果你打算从修改时间开始,你可以有这个
find -newermt '-1 hour'
或者
BEFORE=$(( $(date '+%s') - 3600 )) ## In seconds = 1 hour.
find -type f -printf '%T@ %p\n' | while read -r TS FILE; do TS=${TS%.*}; [[ TS -ge BEFORE ]] && echo "$FILE"; done