admin管理员组文章数量:1596328
Eliminate ^M character using vi(Linux)
Sometimes certain characters(for eg.,^M characters)are placed in a file during a DOS to UNIX conversion.To modify these files with a lot of ^M symbol at the end of every line,using the vi editor,use the following command:(To get the ^M hold the control key, press V then M (Both while holding the control key) and the ^M will appear.)
This command will find all occurances and replace them with nothing. Here,the :%s is a basic search and replace command in vi. It tells vi to replace the regular expression between the first and second slashes (^M) with the text between the second and third slashes (nothing in this case). The g at the end directs vi to search and replace globally (all occurrences). Remove ^M characters at end of lines in vi 有一点需要注意的是,如果采用命令vi file_name将无法看到这些非法字符,也无法执行上面的替换操作,必须以binary方式打开: vi file_name -b
转载于:https://blog.51cto/land611/111325
本文标签: characterEliminateLinuxvi
版权声明:本文标题:(ZT)Eliminate ^M character using vi(Linux) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1728256718a1151106.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论