您将要阅读有关匹配行的sed手册: https://www.gnu.org/software/sed/manual/sed.html 第4章:
以下命令仅在行中将'hello'替换为'world' 不 包含'apple'这个词: sed '/apple/!s/hello/world/' input.txt > output.txt
以下命令仅在行中将'hello'替换为'world' 不 包含'apple'这个词:
sed '/apple/!s/hello/world/' input.txt > output.txt
使用多个块,例如:
sed '/=sometext=/ { /https/b; s/.../.../; }'