我使用以下命令将一些超过 3 天的日志文件移动到名为“old”的文件夹。
find -type f -mtime +3 -exec mv {} old/ \;
运行此命令后,它会移动这些文件并出现以下错误。这是为什么?
mv: `./old/catalina.out-20130410.bz2' and `old/catalina.out-20130410.bz2' are the same file
mv: `./old/catalina.out-20130411.bz2' and `old/catalina.out-20130411.bz2' are the same file
mv: `./old/catalina.out-20130412.bz2' and `old/catalina.out-20130412.bz2' are the same file
mv: `./old/catalina.out-20130413.bz2' and `old/catalina.out-20130413.bz2' are the same file
mv: `./old/catalina.out-20130414.bz2' and `old/catalina.out-20130414.bz2' are the same file
mv: `./old/catalina.out-20130415.bz2' and `old/catalina.out-20130415.bz2' are the same file
mv: `./old/catalina.out-20130416.bz2' and `old/catalina.out-20130416.bz2' are the same file
mv: `./old/catalina.out-20130417.bz2' and `old/catalina.out-20130417.bz2' are the same file
答案1
是old
工作目录的子目录吗?
在这种情况下,您需要使用该选项来告知find
不要进入子目录。old
-maxdepth 0