/*********************************************************************************
 *                  Linux sed 替换第一次出现的字符串
 * 说明:
 *     需要替换配置文件中第一次出现的文本内容。
 *
 *                                       2016-12-16 深圳 南山平山村 曾剑锋
 ********************************************************************************/

一、参考文档:
    How to use sed to replace only the first occurrence in a file?
        http://stackoverflow.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

 

相关文章:

  • 2022-12-23
  • 2021-09-12
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
猜你喜欢
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2021-09-01
  • 2022-01-07
  • 2021-11-09
相关资源
相似解决方案