字符串替換及追加

#替換,將“;hello.desktop;”替換爲“;”

#sed 's/;hello.desktop;/;/g' test>hello.tmpout

#mv hello.tmpout test

 

#追加,將包含“hello”的所有行後追加“this is a example”的新行

#sed '/hello/a\this is a example' test

#追加,將包含“kdkkdkdkdkkd”的所有行尾追加“hello.desktop;”,沒有新行出現

sed -i's/kdkkdkdkdkkd.*/&hello.desktop;/' test



sed awk用法

linux awk命令詳解

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章