【发布时间】:2013-09-11 13:49:42
【问题描述】:
【问题讨论】:
【问题讨论】:
您的帖子类似于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
【讨论】:
-newerct是inode更改时间(如-ctime);不是创建时间(如-newerbt 或-Btime)。 OS X 的find 不支持-printf,但您可以使用brew install findutils 安装GNU find。
-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
和“-”到定义的数量
【讨论】: