이것은의없는 사용자 친화적 인 측면이다.- 일치가 실제로 검색 기준을 올바르게 정의하는 방법을 이해해야합니다. 다음 설명은 GNU find (findutils) 4.4.2를 기반으로합니다.
find
테스트 -atime
, -ctime
, 24 개 시간 기간에 -mtime
일, 그러므로 이제
floor (current_timestamp - file_modification_timestamp/86400)
을 감안할 때 세 개의 파일이 1 시간 전 25 시간 전 수정 된 "파일의 시대"를 정의 할 수와 전 49시간
$ touch -t $(date -d "1 hour ago" +"%m%d%H%M") a.txt
$ touch -t $(date -d "25 hours ago" +"%m%d%H%M") b.txt
$ touch -t $(date -d "49 hours ago" +"%m%d%H%M") c.txt
파일 세 (상기 정의 된 바와 같은)
$ echo "($(date +"%s") - $(stat -c %Y a.txt))/86400" | bc
0
$ echo "($(date +"%s") - $(stat -c %Y b.txt))/86400" | bc
1
$ echo "($(date +"%s") - $(stat -c %Y c.txt))/86400" | bc
2
01 아르 23,516,
여기
$ find -type f -mtime 0 # find files with file age == 0, i.e. files modified less than 24 hours ago
./a.txt
$ find -type f -mtime -1 # find files with file age < 1, i.e. files modified less than 24 hours ago
./a.txt
$ find -mtime 1 # find files with file age == 1, i.e. files modified more than (or equal to) 24 hours ago, but less than 48 hours ago
./b.txt
$ find -mtime +1 # find files with file age > 1, i.e. files modified more than 48 hours ago
./c.txt
이 -mtime 0
및 -mtime -1
동등한 결과를 보여줍니다 않습니다 찾을거야, 위의 주어진.
-mmin
동일한 테스트를 세밀하게 제공합니다. 인수는 24 시간 대신 분이됩니다.
N :
나는대로 다음과 같다 find
$ touch tmp.txt
$ find * -mtime 0
tmp.txt
$ find * -mtime -1
tmp.txt
어떻게 '-mtime 0'이 유용할까요? –
좋은 질문입니다. 한 시간 내에 변경된 파일을 찾을 수 있습니다. 적어도 나는 그것이 할 것이라고 생각합니다. 나는 이것을 실제로 확인하지 않았다. – veiset