Frage

Does the newline sequence or even all escape sequences in a file count as only one character, even though it's written \n?

After I separated a one-line-file into multiple lines, only one character per line was added according to the wc -m output of the terminal.

War es hilfreich?

Lösung

\n is a way of representing a newline character in various languages and programs but as the name suggests, a newline is only stored in a file as a single character.

The backslash helps both computers and humans to realise you are referring to a newline character without you having to actually type one, which would be confusing in a lot of instances.

Andere Tipps

The \n notation is usually used for a single character. Use a hexdump to see the actual bytes, for example xxd.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top