Skip to content
BENIBIX Learn

Line Ending

Development📄 Files & FormatsText

Also known as Newline Character, End of Line, CRLF, LF and CRLF

The hidden character that ends a line of text. Windows uses two, Linux and macOS use one.

Think of it like

Think of it like the Enter key. Some computers press it once, and some press it twice.

Example

Lucy edits a script on Windows and runs it on a Linux server. It fails with a strange \r error until she saves it with LF endings.

Why it matters

Mixed line endings make Git show every line as changed, and they can break scripts. Teams pick one style and stick to it.

Definition

A line ending is the hidden character that marks where a line of text stops. Linux and macOS use one character, the line feed, written \n. Windows uses two, a carriage return and then a line feed, written \r\n. These two styles are called LF and CRLF. Most editors show them the same. Some tools treat them differently, and that causes odd bugs.

Example code

console
$ printf 'hi\r\n' | od -c
0000000   h   i  \r  \n
0000004
This line ends in two hidden characters, a return and a line feed. That is the Windows style.
The top row shows one Hello. Linux ends it with one hidden mark, and Windows with two.

Common mistake

Thinking a change that looks empty is nothing. Often only the line endings changed, and that alone can break a shell script.

Key takeaways

  1. 1
    A hidden mark. It ends each line of text.
  2. 2
    Two styles. LF on Linux and macOS, CRLF on Windows.
  3. 3
    Pick one. Set your editor and Git to match.

Learn it properly