newline

The invisible character that ends a line of text, written \n in most programming languages.

In more detail

Tools that work line by line use newlines to decide where one line ends, and formats such as newline-delimited JSON put one record per line. Windows traditionally ends lines with two characters (carriage return and line feed) and Linux and macOS with one.

Examples

printf 'one\ntwo\n'
find . -print0  # separates names with null bytes instead
An SSE message ends with a double newline: "data: hi\n\n".
printf 'third line\n' >> notes.txt
JSON Lines puts exactly one record before each newline.
A newline inside a Prometheus label value must be escaped as \n.
In Terraform strings \n inserts a newline, as in "Hello from Terraform\n". terraform output -raw prints a value with no trailing newline, which is what a shell variable wants.

Related terms

Taught in

References

Certification courses