系统相关
首页 > 系统相关> > linux 中sed命令如何同时将多个字符替换为指定字符

linux 中sed命令如何同时将多个字符替换为指定字符

作者:互联网

 

001、

(base) root@PC1:/home/test2# cat a.txt                      ## 测试数据
e f k
s g d
a c m
s e g
(base) root@PC1:/home/test2# sed 's/m/Q/g' a.txt            ## 将m替换为Q
e f k
s g d
a c Q
s e g
(base) root@PC1:/home/test2# sed 's/m\|k/Q/g' a.txt        ## 同时将m和k替换为Q
e f Q
s g d
a c Q
s e g
(base) root@PC1:/home/test2# sed 's/m\|k\|a/Q/g' a.txt     ## 同时将m、k和a替换为Q
e f Q
s g d
Q c Q
s e g

 

标签:字符,test2,##,PC1,sed,base,linux,home
来源: https://www.cnblogs.com/liujiaxin2018/p/16593043.html