Search code examples
bashunixterminalnewlinewc

newline sequence counts as one character?


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.


Solution

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