Linux sed 替换第一次出现的字符串

时间:2023-03-08 19:10:36
Linux sed 替换第一次出现的字符串
/*********************************************************************************
* Linux sed 替换第一次出现的字符串
* 说明:
* 需要替换配置文件中第一次出现的文本内容。
*
* 2016-12-16 深圳 南山平山村 曾剑锋
********************************************************************************/ 一、参考文档:
How to use sed to replace only the first occurrence in a file?
http://*.com/questions/148451/how-to-use-sed-to-replace-only-the-first-occurrence-in-a-file 二、测试代码:
sed -i '0,/IP = .*/s/IP = .*/IP = 10.10.10.10/' /usr/share/config.conf