sed 命令总结

测试文件test.txt内容

aaa
ab
abcd
eeee

1 匹配特定字符串

sed -n '/aaa/p'  test.txt 

2 替换特定字符串

sed -n 's/aaa/ccc/p'  test.txt 

3 在文件中替换特定字符串

sed -i 's/aaa/ccc/g'  test.txt 

posted @ 2020-07-23 18:17  ZhaoKevin  阅读(100)  评论(0编辑  收藏  举报