有没有办法只用 find 命令在文件名前加上一个字符串?
所以这个:
201a.txt
201b.png
...
Run Code Online (Sandbox Code Playgroud)
变成这样:
foo_201a.txt
foo_201b.png
...
Run Code Online (Sandbox Code Playgroud)
这个:
find . -name '201*' -execdir mv {} foo_{} \;
Run Code Online (Sandbox Code Playgroud)
不起作用,因为该{}
部分包含./
文件名中的前导,因此尝试写入foo_./201*
.
如果仅使用 find 无法做到这一点,那么将字符串添加到文件名的最便携(阅读:只有 coreutils,没有 shell 脚本,最容易理解)的方法是什么?