Thursday, February 2, 2017

Remove ^M character from VI Unix

Once we copied the file from windows to unix machine we see the following ^M when we try to edit the file with VI .

The ^M is a carriage-return character. If you see this, you're probably looking at a file that originated in the DOS/Windows world,
where an end-of-line is marked by a carriage return/newline pair, whereas in the Unix world, end-of-line is marked by a single newline.

Vi test.sql

-- Please make any necessary changes as needed.^M
^M
^M
CREATE SEQUENCE  scott.emp MINVALUE 100 MAXVALUE 999999999999999999999 INCREMENT BY 1 START WITH 100 CACHE 400 NOORDER  NOCYCLE ;^M
^M



WORKAROUND :

which dos2unix
/usr/local/bin/dos2unix

/usr/local/bin/dos2unix test.sql

Dos2Unix: Cleaning file test.sql ...

No comments:

Post a Comment