Unix2dos

From Leo's Notes
Revision as of 02:55, 12 September 2019 by Leo (talk | contribs) (Created page with "A newline is denoted with different control characters depending on the operating system you are on. Linux denotes newlines with a line feed ({{code|LF}}, denoted typically a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 12 September 2019, at 02:55.

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