在Linux中查找和replace文件

我知道如何通过文件查找和replace某些string,但是我感兴趣的是如何find并replace整个文件? 例如,我想查找所有在特定时间修改的info.php文件,并将其replace为另一个文件。

就像是:

 find -f /home/ -name php.info -exec cp -f /var/somefile.php {} 

要么?

我不知道如何添加,所以它只会search被修改的文件,例如,在20.1.2014

find一个-mtimefilter,你可以使用它。

为了更详细的search和replace,你也可以使用一个shell循环。

  find WHATEVER | while read f ; do ## add your own test here, like … # fgrep -qs "do not delete" "$f" && continue cp -f /what/ever "$f" done 

为了提供确切的datefind ,请使用-newermt 2014-01-20 \! -newermt 2014-01-21的行-newermt 2014-01-20 \! -newermt 2014-01-21 -newermt 2014-01-20 \! -newermt 2014-01-21