ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

linux 中sed命令删除^M

linux 中sed命令删除^M

 

001、方法1

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt
aaa
bbb
cc
ddd
ee
[root@PC1 test]# cat -A a.txt
aaa^M$
bbb^M$
cc^M$
ddd^M$
ee^M$
[root@PC1 test]# sed 's/\xd//' a.txt | cat -A
aaa$
bbb$
cc$
ddd$
ee$

image

 .

002、

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt
aaa
bbb
cc
ddd
ee
[root@PC1 test]# cat -A a.txt
aaa^M$
bbb^M$
cc^M$
ddd^M$
ee^M$
[root@PC1 test]# sed 's/^M//g' a.txt | cat -A   ## ^M使用ctrl + v,然后ctrl + m打出来
aaa$
bbb$
cc$
ddd$
ee$

image

 。

 

返回列表