Unix2dos

From Leo's Notes
Revision as of 00:10, 15 June 2020 by Leo (talk | contribs) (Leo moved page Newline to Unix2dos: article on using unix2dos)
This page was last edited on 15 June 2020, at 00:10.

A newline is denoted with different control characters depending on the operating system you are on.

Linux denotes newlines with a line feed (LF, denoted typically as \n.

Windows and DOS denotes newlines with both a carriage return and a line feed (CR LF), denoted typically as \r\n.

Conversion

On Linux, use any one of:

## From \r\n to \n:
$ dos2unix
$ cat file.txt | tr -d '\r' > file2.txt

## From \n to \r\n:
$ unix2dos