【问题标题】:Unable to rename files recursively using xargs command无法使用 xargs 命令递归地重命名文件
【发布时间】:2019-01-29 22:49:23
【问题描述】:

我必须递归地重命名与模式匹配的所有文件。我正在使用以下命令。

find . -type f -iname 'dev*' | xargs -I{} mv $1 echo '/dev-profile/prod-profile'

当我运行上述命令时,我收到以下错误 missing destination file operand after /dev-profile/prod-profile

我需要递归替换所有文件。我哪里出错了。

【问题讨论】:

  • 用文字解释你希望你的代码做什么。提供一些示例预期源路径及其对应的目标路径。然后我们可以解释如何最好地整理您的代码。

标签: unix xargs


【解决方案1】:

处理xargs 中的参数经常会与bash -c ... _ 混淆。

如果你有 GNU Parallel,你可以避免这种混乱,并且可能会做这样的事情:

find . -type f -iname 'dev*' | parallel mv {} /dev-profile/prod-profile

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-15
    • 2016-01-31
    • 2014-03-03
    • 2012-06-13
    • 2018-11-28
    • 2016-04-18
    • 2020-11-23
    相关资源
    最近更新 更多