sed 搜索並替換


find . -type f -exec sed -i "s/std=c++11/std=c++14/g" {} \;

搜索當前目錄下的文件,把std=c++11替換成std=c++14,注意{}\之間有個空格。

全詞替換

$ echo "bar embarassment" | sed "s/\bbar\b/no bar/g"
no bar embarassment

\b in regular expressions match word boundaries (i.e. the location between the first word character and non-word character):


免責聲明!

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



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