Linux sed 替換第一次出現的字符串


/*********************************************************************************
 *                  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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM