3

我谷歌查找文档,并写了这个

find . -type f -depth 1 -Btime 1

但是,我不工作?我怎样才能完成这项工作?

4

3 回答 3

4

-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.
于 2013-09-07T16:49:36.820 回答
0
find . -type f -depth 1 -Btime -1

和“-”到定义的数字

于 2013-09-07T16:52:42.457 回答
0

您的帖子与此线程类似。无论如何,你可以有这样的命令。

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
于 2013-09-07T16:14:03.377 回答