Troubleshooting
Problem
Removing ^M from Files in vi :g/^M/s///g how to remove caret M (control char, return char, new line) in unix, vi editor :g/^M/s///g
Symptom
PART: UNIX, vi
COMPONENT: vi
OS: HP-UX - 10.2
DATABASE: Oracle -
7.3.4
WEB SERVER: <None> - <None>
WEB BROWSER: <None> - <None>
Cause
Resolving The Problem
In transferring a file between OSes, occasionally control or return characters
are placed at the end of each line. These are typically only visible in View
mode of vi.
To remove these characters from a file:
--Open the
file in View mode (command view [filename]).
--Execute the following
command
:g/^M/s///g
Note: To enter the ^M into the command, type
CTRL+v and CTRL+m consecutively.
Save the file. (It will probably be
necessary to force save using :w!)
------------------
in some cases you
might need to enter the command as
:%s/^M//g
Historical Number
PRI48544
Product Synonym
[<p><b>]Fact[</b><p>];
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21544848