【问题标题】:how do I fix whitespace in my SED causing issues如何修复导致问题的 SED 中的空格
【发布时间】:2022-01-22 07:49:53
【问题描述】:

我在使用 SED 时遇到问题

我要替换的东西:

image: thing:1.2.3

我想要的:

image: myrepo/folder1/folder2/opensource/thing/thing:1.2.3

我得到了什么:

image: myrepo/folder1/folder2/opensource/thing/ thing:1.2.3

我在做什么:

sed -e 's/image:\s/image:\ myrepo\/folder1\/folder2\/opensource\/thing\//' thing-deployment.yaml > thing-deployment.yaml.UPDATED

我想我已经接近了,但我错过了一些东西。请问是什么?

【问题讨论】:

  • awk '$2 = "myrepo/folder1/folder2/opensource/thing/" $2'

标签: sed


【解决方案1】:

您可以更改分隔符以避免代码中出现太多反斜杠。

使用sed

$ sed 's|th.*|myrepo/folder1/folder2/opensource/thing/&|' input_file
image: myrepo/folder1/folder2/opensource/thing/thing:1.2.3

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-02
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    • 2020-07-19
    • 1970-01-01
    • 2019-08-27
    相关资源
    最近更新 更多