我有一个名为“test-file”的文件。它只有以下两行(第一行带有# 符号,第二行内容相同但没有散列):
#contents of line
contents of line
Run Code Online (Sandbox Code Playgroud)
我想使用 sed 命令更新/替换第二行的内容。我知道它的简单语法,例如:
sed -i 's/.*contents of line.*/updated contents/' test-file
Run Code Online (Sandbox Code Playgroud)
但是上面的命令正在替换这两行,而我不想在前面用 # 符号更新第一行。