I google the find doc,and wrote this
find . -type f -depth 1 -Btime 1
howerver ,I doesn`t work? how can I get this done?
-Btime 5
matches files that were created five days ago (where 4.1 is rounded up to 5 and 5.1 is rounded up to 6). If you meant files created between now and five days ago, use -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
Also -maxdepth 1
or -mindepth 1 -maxdepth 1
is faster than -depth 1
. -depth 1
traverses all files under the directory tree.
The format that can be used with -atime
, -Btime
, -ctime
, and -mtime
is described under -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.
Your post is similar to this thread. Anyhow you can have a command like this.
find -newerct 'now -1 hour'
Or
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
If you plan to base it from modification time, you can have this
find -newermt '-1 hour'
Or
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