且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 Sed 替换包含字符串的整行

更新时间:2022-11-22 13:17:33

您可以使用 change 命令替换整行,并使用 -i 标志使就地更改.例如,使用 GNU sed:

You can use the change command to replace the entire line, and the -i flag to make the changes in-place. For example, using GNU sed:

sed -i '/TEXT_TO_BE_REPLACED/c\This line is removed by the admin.' /tmp/foo