Chinaunix首页 | 论坛 | 博客
  • 博客访问: 607340
  • 博文数量: 197
  • 博客积分: 7001
  • 博客等级: 大校
  • 技术积分: 2155
  • 用 户 组: 普通用户
  • 注册时间: 2005-02-24 00:29
文章分类

全部博文(197)

文章存档

2022年(1)

2019年(2)

2015年(1)

2012年(100)

2011年(69)

2010年(14)

2007年(3)

2005年(7)

分类: LINUX

2005-04-21 14:36:53


We
can easily correct the dreaded '^M' at the end of our Unix lines, or make files have more than one
line in DOS by:

To change from (DOS) to just (Unix):
:set fileformat=unix
:w

Or to change back the other way:
:set fileformat=dos
:w

It also works for Apple land:
:set fileformat=mac
:w


另一种方法
remove CTRL-M characters from a file in UNIX

Something useful yet many don't know about it:

Using sed (the stream editor)- try this:
sed -e "s/^M//" FileName > NewFileName

To get ^M you hold down the CTRL key, press V then while still holding CTRL, press M.

While using vi:
% vi filename

While in vi and vim, hit : to get into command mode, then type:
:%s/^M//g

While in Emacs, go to the beginning of the document and
Type:
M-x replace-string RET C-q C-m RET RET

where "RET" means press-the-return-key and C-q and C-m mean hold-the-CTRL-key-and press-the-m-(or q)-key.


阅读(1074) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~