^M behind operating system version?

57 Views Asked by At

I am currently writing a perl script to extract data from a log file and create statements using the data in a new file.

In this new file, one particular data that I've extracted and used here is the operating system's version. It shows Windows XP Service Pack 3^M. I noticed this ^M only appears when I edit using vi. When I display the contents of the file normally using command prompt or PuTTy with more, it only shows Windows XP Service Pack 3.

Can anyone explain or refer to me a link on why there's an ^M? I've found nothing on Google search. All I know is that it has something to do between Windows and Unix or Linux operating systems.

2

There are 2 best solutions below

1
On BEST ANSWER

vi and familiars (you're probably actually using vim) display the the return character as ^M. Since line endings in unix and windows are different, you get this displayed instead of an actual line break.

0
On

DOS and Unix (and Mac?) have different "newline" conventions. The vi program is doing the correct thing. The more program is too. It is a pager and is hiding this from you.

Using the perl chomp() function, it should clean up any EOL weirdness.