單一檔案

如 story.txt 的內容如下

Connection pool
From Wikipedia, the free encyclopedia
Jump to: navigation, search <find me>

可以下指令使用
#cat story.txt | sed "s/<find me>/yes/g"
Connection pool
From Wikipedia, the free encyclopedia
Jump to: navigation, search yes
將 "<fine me>" 取代成 "yes"

若是要直接修改檔案,請加上 -i
#sed -i "s/<find me>/yes/g" story.txt

多個檔案
# find *.conf | xargs -i sed -i 's/senor/sensor/g' {}

arrow
arrow
    文章標籤
    sed
    全站熱搜
    創作者介紹
    創作者 wbkuo 的頭像
    wbkuo

    長島冰茶的工程師筆記

    wbkuo 發表在 痞客邦 留言(0) 人氣()