我在文件中有这一行:
ULNET-PA,client_sgcib,broker_keplersecurities
,KEPLER
我尝试去掉 ^M(回车)字符,所以我使用了:
sed 's/^M//g'
然而,这确实删除了 ^M 之后的所有内容:
[root@localhost tmp]# vi test
ULNET-PA,client_sgcib,broker_keplersecurities^M,KEPLER
[root@localhost tmp]# sed 's/^M//g' test
ULNET-PA,client_sgcib,broker_keplersecurities
我想要获得的是:
[root@localhost tmp]# vi test
ULNET-PA,client_sgcib,broker_keplersecurities,KEPLER
Use tr
:
tr -d '^M' < inputfile
(Note that the ^M
character can be input using Ctrl+VCtrl+M)
编辑:作为建议 by 格伦·杰克曼,如果你正在使用bash
,你也可以说:
tr -d $'\r' < inputfile
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)