Hy guys.

I got a noob question, tried to look on the internet without success. Look the following notice:

Linux kernel exceeds 15 million lines of code

Now, how many characters are in one line ? I opened my text editor to the figure this out and got this crazy thing:



  • 3
    LOC or Lines of Code is not measured by how many characters you can fit into a line. If I'm right, that 20000 number depends on the text editor you're using. For more details on LOC, visit en.wikipedia.org/wiki/Source_lines_of_code.
    – Bibhas
    Jan 19, 2012 at 14:11
  • 1
    Before we tell you the answer to this, you'll need to obtain a piece of string and measure its length …
    – JdeBP
    Jan 19, 2012 at 15:30

2 Answers 2


Your question cannot really be reasonably answered. You're kind of asking the wrong question here.

There is no constant number of characters per line. A line, in the general, technical sense, can be an arbitrarily long sequence of characters that ends with a newline character \n. If that character just doesn't occur, the line can become extremely long. It really depends on the contents of what you write. It's not like in a word processor (or on this web site), where line breaks occur automatically, and the possible line length depends on font size, or page orientation.

In source code, this is also coupled with the difficulty of determining what exactly a line of code is. Do source code comments, that aren't actually code, i.e. processing instructions, count? Do empty lines (lines with only whitespace) count? For source code, there's a metric called Source Lines of Code, or SLOC. This article has some more information about it.

In a linked article, the H states:

It's worth noting that these figures do include the comments, blank lines, documentation, scripts and userland tools included with the kernel (find . -type f -not -regex '\./\.git.*' | xargs cat | wc -l).

So it's really the number of newline characters, including comments, empty lines, etc. of all files excluding the revision control metadata (git) files. This measures the physical lines (counting the \n characters), and really depends on things like source code formatting.


Well, for the linux kernel, there is actually a hard limit of 80 characters per line enforced.

However, you can figure out the average line length by taking the the file sizes and dividing by the rough number of lines (or using any line/character tool such as wc)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .