ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

linux 中sed命令删除^M

2026/10/5 18:34:53 拓冰建站 浏览量
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

 。