如何使用find命令获取昨天创建的文件?

Ama*_*nem 5 command-line scripts find date

与 find 一起使用什么选项来获取昨天在 Linux 脚本上创建的文件?

以下试验不起作用:

find /log/bssuser/CDR/Postpaid_CDR_Log/ -newer yesterday
Run Code Online (Sandbox Code Playgroud)

或者

find -mtime 24

-----------------------------
the below command get files for today 10/10

[bssuser@t-bss-bill-app-01 Amany]$ find -newermt yesterday -ls
142619049    4 drwxrwxr-x   2 bssuser  bssuser      4096 Oct 10 08:40 .
142619072    4 -rwxrwxr-x   1 bssuser  bssuser      2376 Oct 10 08:40 ./test_am.sh
142619050    4 -rw-rw-r--   1 bssuser  bssuser       433 Oct 10 08:40 ./errors.csv
142619058    4 -rw-rw-r--   1 bssuser  bssuser       323 Oct 10 08:40 ./logs.csv
Run Code Online (Sandbox Code Playgroud)

ste*_*ver 5

find命令的-[acm]time谓词很棘手。

特别是,-mtime n匹配修改时间介于当前时间nn+124 小时之前的文件。所以

find . -mtime 1
Run Code Online (Sandbox Code Playgroud)

将查找 24 到 48 小时之前的文件。要查找与日历日相关的文件,GNUfind-daystart选项,因此要查找在前一个日历日修改的文件,您可以使用

find . -daystart -mtime 1
Run Code Online (Sandbox Code Playgroud)

也可以看看:


sot*_*rov 3

您可以使用:

find -newermt yesterday -ls
Run Code Online (Sandbox Code Playgroud)

它是如何工作的,详细信息来自man find

-newerXY reference
       Succeeds if timestamp X of the file being considered is newer than timestamp Y of the file reference.  The letters X and Y
       can be any of the following letters:

       a   The access time of the file reference
       B   The birth time of the file reference
       c   The inode status change time of reference
       m   The modification time of the file reference
       t   reference is interpreted directly as a time

       Some combinations are invalid; for example, it is invalid for X to be t.  Some combinations are  not  implemented  on  all
       systems;  for  example  B is not supported on all systems.  If an invalid or unsupported combination of XY is specified, a
       fatal error results.  Time specifications are interpreted as for the argument to the -d option of GNU date.  If you try to
       use  the  birth  time of a reference file, and the birth time cannot be determined, a fatal error message results.  If you
       specify a test which refers to the birth time of files being examined, this test will fail for any files where  the  birth
       time is unknown.
Run Code Online (Sandbox Code Playgroud)