Domanda

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.

È stato utile?

Soluzione

\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.

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top