【问题标题】:Jenkinsfile, "find", ignoring some hidden directories and other foldersJenkinsfile,“查找”,忽略一些隐藏目录和其他文件夹
【发布时间】:2021-01-23 22:02:38
【问题描述】:

我现在正在使用“Jenkinsfile”。 我需要按文件扩展名的类型“查找”,执行“sed -i”,忽略一些隐藏目录和其他文件夹。

我不知道正确的语法。

例子:

def replacePath() {  
sh 'sed -i "s/A\\/B/C\\/D\\/E\\/F\\/G\\/A\\/B\\/opt\\/C/g" \$(find . -type f -name "*.json" not path ..... -print0) '

【问题讨论】:

    标签: sed find


    【解决方案1】:

    尝试使用xargs,如下所示:

    find . -type f -name '*.json' ... -print0 | xargs -0 sed -i 's/pattern/replacement/g'
    

    使用xargs 比在命令行上使用$(...) 传递参数的问题更少,尤其是与-print0 一起使用时,因为xargs 可以处理包含shell 元字符的文件名。

    【讨论】:

      猜你喜欢
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 2012-09-25
      • 2013-10-20
      • 1970-01-01
      • 2021-08-26
      • 2015-10-08
      相关资源
      最近更新 更多