示例数据文件 /tmp/file
1 This is line one 2 This is line two 3 This is line three 4 This is line four 5 This is line one 6 This is line two 7 This is line three 8 This is line four
示例2
将第8行的four替换为your text ,注意第4行也有four,但是我们只替换第8行的
# sed '8s/four/your text/g' /tmp/file
1 This is line one 2 This is line two 3 This is line three 4 This is line four 5 This is line one 6 This is line two 7 This is line three 8 This is line your text
示例1
将第5行的“one”替换为“your text”
# sed '5s/one/your text/g' /tmp/file
1 This is line one 2 This is line two 3 This is line three 4 This is line four 5 This is line your text 6 This is line two 7 This is line three 8 This is line four
日期:2020-06-02 22:17:33 来源:oir作者:oir