Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10731912
  • 博文数量: 2905
  • 博客积分: 20098
  • 博客等级: 上将
  • 技术积分: 36298
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-23 05:00
文章存档

2012年(1)

2011年(3)

2009年(2901)

分类: LINUX

2009-03-23 11:13:08

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:
:%s/^M//g
(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).
阅读(927) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~