【发布时间】:2020-07-07 12:54:09
【问题描述】:
如何使用 sed 定位字符串,并在字符串后面添加另一个文件中的文本?
文件 1:
stage ('Clone Repo31') {
steps {
git credentialsId: '', url: '/stash/scm/'
}
}
stage ('Zip Repo31') {
steps {
sh"""
tar --exclude='*.tar' -cvf .tar *
"""
}
}
steps {
git credentialsId: '', url: '/stash/scm/'
}
}
stage ('Zip Repo32') {
steps {
sh"""
tar --exclude='*.tar' -cvf .tar *
"""
}
}
文件 2:
randomRepo.git
differentRandomRepo.git
我希望能够使用 sed 读取第二个文件,并在每次出现 stash/scm/ 后添加第二个文件中每一行的内容
期望的输出:
stage ('Clone Repo31') {
steps {
git credentialsId: '', url: '/stash/scm/randomRepo.git'
}
}
stage ('Zip Repo31') {
steps {
sh"""
tar --exclude='*.tar' -cvf .tar *
"""
}
}
steps {
git credentialsId: '', url: '/stash/scm/differentRandomRepo.git'
}
}
stage ('Zip Repo32') {
steps {
sh"""
tar --exclude='*.tar' -cvf .tar *
"""
}
}
这可以用 sed 完成吗?我在从列表文件中读取它时遇到问题,这很令人困惑,因为它有很多斜杠。我已经能够使用正常的 sed 替换,但我不知道如何通过读取另一个文件来进行替换。
【问题讨论】:
-
为什么这个话题被关闭了?我正在为它写一个答案,它是关于编程的!
-
@EnricoMariaDeAngelis 这个问题没有显示任何研究,这正是 downvote 按钮工具提示所标记的。问题至少应该说明解决问题的方法。
-
这是否使它偏离主题?
标签: linux bash jenkins sed terminal