您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

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

您可以用来find@H_301_2@递归查找所有匹配文件

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

什么'{}'@H_301_2@和\;@H_301_2@是谁?

-exec@H_301_2@参数使findrename@H_301_2@对找到的每个匹配文件执行。'{}'@H_301_2@将被替换为文件的路径名。最后一个标记\;@H_301_2@仅用于标记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.
@H_301_2@
其他 2022/1/1 18:15:38 有405人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶