What is the meaning of CR + LF?
-
Cripes, I read that as "someone texted me crlf" hence the close vote. Nice interpretation, Farseeker. :) – EEAA Nov 03 '10 at 05:15
-
@ErikA - I did too, but I decided to make it on-topic. Still belongs on SU though. – Mark Henderson Nov 03 '10 at 05:19
-
Is it seriously easier to ask a question on server fault and wait for an answer than to spend 30 seconds googling? – micmcg Nov 03 '10 at 05:50
-
@micmg - the idea is that next time someone *else* googles for CRLF, they find our site and our answers here. – Mark Henderson Nov 03 '10 at 09:18
-
Or the already detailed wikipedia entry on newlines? I mean how does this even belong on serverfault, what does it have to do with servers? – micmcg Nov 03 '10 at 23:04
-
It has little to do with SysAdmin. I vote to close it. – sybreon Nov 04 '10 at 03:23
2 Answers
CR LF means "Carriage Return, Line Feed" - it's a DOS hangover from the olden days from when some devices required a Carriage Return, and some devices required a Line Feed to get a new line, so Microsoft decided to just make a new-line have both characters, so that they would output correctly on all devices.
Windows programs expect their newline format in CRLF (\r\n
). *nix expect just LF data (\n
). If you open a Unix text document in Notepad on windows (earlier than Windows 10 build 1903 released May 2019 which added support for Unix line endings), you'll notice that all of the line breaks disappear and the entire document is on one line. That's because Notepad expects CRLF data, and the Unix document doesn't have the \r
character.
There are applications that will convert this for you on a standard *nix distro (dos2unix
and unix2dos
)
For those wondering, a carriage return and a line feed differ from back in Typewriter days, when a carriage return and a line feed were two different things. One would take you to the beginning of the line (Carriage Return) and a one would move you one row lower, but in the same horizontal location (Line Feed)
![](../../users/profiles/7709.webp)
- 68,316
- 31
- 175
- 255
-
3`Carriage Return` = Send the cursor (print-head on old teletype systems) to the beginning of the line. `Line Feed` = Advance the terminal one line (advance the paper one line). In unix and some printers, CR is implied by LF. – sysadmin1138 Nov 03 '10 at 05:18
-
@sysadmin - I was just editing my answer to include that info ;) – Mark Henderson Nov 03 '10 at 05:21
-
@MarkHenderson Did you mean same vertical location in your answer's last line? – Vicrobot Sep 22 '18 at 15:18
-
@Vicrobot no, I think he meant what he wrote ("same horizontal location"). The way I understand it is that when you move straight down, only your vertical location changes; your horizontal location stays the same. – ma11hew28 Jan 24 '21 at 15:27
It's a Carriage Return (\r
, ASCII code 13) followed by a Line Feed (\n
, ASCII code 10).
![](../../users/profiles/7360.webp)
- 45,019
- 5
- 78
- 84
-
Classic case of the first answer gets all the votes. To try and change the world, have an upvote. – Reversed Engineer May 22 '18 at 19:54