查找多个文件并在Linux中重命名它们

查找多个文件并在Linux中重命名它们,第1张

查找多个文件并在Linux中重命名它们

您可以用来

find
递归查找所有匹配文件:

$ find . -iname "*dbg*" -exec rename _dbg.txt .txt '{}' ;

编辑: 什么

'{}'
;
是谁?

-exec
参数使find
rename
对找到的每个匹配文件执行。
'{}'
将被替换为文件的路径名。最后一个标记
;
仅用于标记exec表达式的结尾。

手册页中对找到的所有内容进行了很好的描述:

 -exec utility [argument ...] ;         True if the program named utility returns a zero value as its         exit status.  Optional arguments may be passed to the utility.         The expression must be terminated by a semicolon (``;'').  If you         invoke find from a shell you may need to quote the semicolon if         the shell would otherwise treat it as a control operator.  If the         string ``{}'' appears anywhere in the utility name or the argu-         ments it is replaced by the pathname of the current file.         Utility will be executed from the directory from which find was         executed.  Utility and arguments are not subject to the further         expansion of shell patterns and constructs.


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5012099.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-14
下一篇2022-11-15

发表评论

登录后才能评论

评论列表(0条)

    保存