我谷歌find doc,写了这个
find . -type f -depth 1 -Btime 1
但是,IT不起作用?我怎么能这样做?
答案 0 :(得分:3)
-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.
答案 1 :(得分:0)
您的帖子类似于this thread。无论如何,你可以拥有这样的命令。
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
答案 2 :(得分:0)
find . -type f -depth 1 -Btime -1
和“ - ”到num定义的