• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

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.
0
marcoo
Asked:
marcoo
1 Solution
 
emikoCommented:
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
here.

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
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now