Joh*_*ica 15
这是一个无害的错误,您可以通过-depth选项摆脱它.
find . -depth -type d -name 'thefoldername*' -exec mv {} newfoldername \;
Run Code Online (Sandbox Code Playgroud)
查找的正常行为是处理目录然后递归到它们中.由于你已经重命名,所以当它试图递归时会发现抱怨.该-depth选项告诉find首先递归,然后处理目录.
它缺少-execdir选项!正如 find 的手册页中所述:
-execdir command {};
Run Code Online (Sandbox Code Playgroud)
与 类似 -exec,但指定的命令是从包含匹配文件的子目录运行的,该子目录通常不是您开始查找的目录。
find . -depth -type d -name 'thefoldername*' -execdir mv {} newfoldername \;