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 UNIXSomething 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.
阅读(1092) | 评论(0) | 转发(0) |