your mail

Andrew L. Gould algould at datawok.com
Fri Jan 16 06:45:23 PST 2004


On Friday 16 January 2004 07:45 am, David Fleck wrote:
> On Thu, 15 Jan 2004, Evan Sayer wrote:
> > FreeBSD-
> > Please help, this is really important.  I was told that i could get rid
> > of the ^m symbols at the  end of the lines in my web page's html code
> > by using sed.  They said to execute sed "s//^m^m" index.html >
> > index.html or something like that.  This got rid of everything in the
> > file.  I really need this back, so any help would be greatly
> > appreciated.
>

In Windows, the end of a line is represented by the carriage return and the 
new line characters.  Unix uses only the new line character. Although the 
carriage return is usually keyed as '\r', I've noticed that it appears as 
"^M" in certain editors.

One of the safest ways to convert between Windows and Unix formats is to use 
the unix2dos port at /usr/ports/converters/unix2dos.  The port installs the 
executable files unix2dos and dos2unix.

To convert a Windows file to Unix (to remove "^M" from the end of each line, 
execute:

dos2unix <filename>

To convert a Unix file to Windows (to add "^M" to the end of each line), 
execute:

unix2dos <filename>

This way, you will not risk mistyping code that is gibberish to non-scripters.

Best of luck,

Andrew Gould



More information about the freebsd-questions mailing list