Strange chars..

I have made a c program that fetches mail from a pop3 server. It saves the messages in the users mailbox file /var/spool/mail/username and when i edit it i see this ^M on the end of every line. Does anybody have any ideas of why those strange chars appear in the file?... I tried to sed them oout with
sed 's/"^M"/" "/g' but without any success.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The cntl-M (0d in hex) is a Carriage Return. I think windows uses
this ASCII character as an end of line character.

What you probably want is a cntl-J (0a in hex). You should be
able to sed it out but maybe not with the command you show

Try this to replace ^M with a newline. Put the following in a file called foo.
Note that ^M is typed in (using vi) using "control-V control-M". Don't use shift 6!:

s/^M/\         <- hit enter to go to next line

Then run the command: sed -f foo yourInputFile > goo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.