Search This Blog

Saturday, March 8, 2008

Remove Control M (^M) Characters From Unix File

If you see control M characters(^M) in a file in UNIX, don't worry there is a very simple way to convert the file in UNIX format.
The command is


dos2unix filename [newfilename]


e.g. remove control characters from file abc.txt

dos2unix abc.txt abc.txt #this will replace abc.txt and remove control characters

dos2unix abc.txt xyz.txt #a new file xyz.txt will be created after removing control characters

So isn't that simple lovely command took off all the worries.

4 Comments:

Unknown said...

Hi Suresh,

Took good effort to post these articles. Some are new to me. Please don't leave posting articles. Good stuff.

Bye
Hemanth

Anonymous said...

Hi Suresh,

If I am using an concurrent job to ftp the file and then SQL Load, how do I remove the control M characters in this case.

Thanks, Sanjana.

Suresh Vaishya said...

use dos2unix command in the shell script after file is FTPed.

Suresh

sap upgrade challenges said...

This site has always has something to offer.This is a very tricky problem which many professionals also fail to understand. Thanks for the information.

Copyright (c) All rights reserved. Presented by Suresh Vaishya