[NBLUG/talk] changeing line breaks.

Ron Wickersham rjw at alembic.com
Sun Oct 19 19:05:02 PDT 2003


---snip---

> Do you know how the characters are represeted as? Like \n in linux is
> what to windows?
>
> Maybe I can sed it out like:
>
> sed -e s/\\n/\\n\\windowbreak/g
>
> And add whatever represents a windows return is replaced with the
> "\windowsbreak" in the example above. Then it will work in both?
> Maybe this is not possible?

windows uses newline (\n) followed by return (\r) while unix uses the
newline only.   so your sed line will do fine adding \r for windowbreak.

since the line endings are different, you need to convert between
them, a single file won't work (always correctly) in both msdos and unix.

in going the other way, editing a dos file in vi and keeping it in unix,
you can do :%s/
//g and get rid of all the extra carriage returns.
(you get the 
 above with <cont>V followed by <return>).

vim has some automatic scheme that usually does the right thing for you,
but you can force it with :set fileformat unix or :set fileformat dos
before you save the file.

-ron



More information about the talk mailing list