Ubuntu Linux:在特定时间之间查找文件?

dig*_*ast 19 linux grep find ubuntu

我发现了一个叫做使用 Find/Grep 在一天中的特定时间之间搜索文件的 SO

基于它和一个名为Grep 命令的 Unix SE来查找包含文本字符串的文件并移动它们,我最终得到:

find . -type f -mtime -20 | grep -v -e " \(0[012345]\|18\|19\|2[0123]\)" | xargs mv -t daytime/
Run Code Online (Sandbox Code Playgroud)

但它正在移动所有文件。我使用 Ubuntu 有什么不同吗?

我想要做的就是将上午 6 点到下午 6 点之间的所有文件移动到另一个目录。任何建议,将不胜感激。

mrk*_*rks 34

其实find已经有了这个功能:

find . -newermt "2013-01-01 00:00:00" ! -newermt "2013-01-02 00:00:00"
Run Code Online (Sandbox Code Playgroud)

从联机帮助页:

-newerXY reference
       Compares  the timestamp of the current file with reference.  The
       reference argument is normally the name of a file  (and  one  of
       its  timestamps is used for the comparison) but it may also be a
       string describing an absolute time.  X and  Y  are  placeholders
       for other letters, and these letters select which time belonging
       to how reference is used for the comparison.

       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  argu?
       ment  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  deter?
       mined,  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)