sloccount <directory>

Count lines of source code excluding blank lines and comments

Much more accurate than other methods mentioned here straight out of the box.
Sample Output
SLOC	Directory	SLOC-by-Language (Sorted)
263110  include         ansic=261507,cpp=1561,asm=42
33895   scripts         ansic=20542,perl=7062,cpp=1795,sh=1714,yacc=1289,
                        lex=1045,python=448
27314   arch            ansic=26884,cpp=430
0       block           (none)
0       crypto          (none)
0       drivers         (none)
0       firmware        (none)
0       fs              (none)
0       init            (none)

1
By: BohrMe
2011-05-06 13:51:27

These Might Interest You

What Others Think

Full sample output: sloccount . Creating filelist for arch Creating filelist for block Creating filelist for crypto Creating filelist for drivers Creating filelist for firmware Creating filelist for fs Creating filelist for include Creating filelist for init Creating filelist for ipc Creating filelist for kernel Creating filelist for lib Have a non-directory at the top, so creating directory top_dir Adding /usr/src/kernels/2.6.35.12-90.fc14.i686/./Makefile to top_dir Creating filelist for mm Adding /usr/src/kernels/2.6.35.12-90.fc14.i686/./Module.symvers to top_dir Creating filelist for net Creating filelist for samples Creating filelist for scripts Creating filelist for security Creating filelist for sound Adding /usr/src/kernels/2.6.35.12-90.fc14.i686/./System.map to top_dir Creating filelist for tools Creating filelist for usr Creating filelist for virt Adding /usr/src/kernels/2.6.35.12-90.fc14.i686/./vmlinux.id to top_dir Categorizing files. Finding a working MD5 command.... Found a working MD5 command. Computing results. SLOC Directory SLOC-by-Language (Sorted) 263110 include ansic=261507,cpp=1561,asm=42 33895 scripts ansic=20542,perl=7062,cpp=1795,sh=1714,yacc=1289, lex=1045,python=448 27314 arch ansic=26884,cpp=430 0 block (none) 0 crypto (none) 0 drivers (none) 0 firmware (none) 0 fs (none) 0 init (none) 0 ipc (none) 0 kernel (none) 0 lib (none) 0 mm (none) 0 net (none) 0 samples (none) 0 security (none) 0 sound (none) 0 tools (none) 0 top_dir (none) 0 usr (none) 0 virt (none) Totals grouped by language (dominant language first): ansic: 308933 (95.26%) perl: 7062 (2.18%) cpp: 3786 (1.17%) sh: 1714 (0.53%) yacc: 1289 (0.40%) lex: 1045 (0.32%) python: 448 (0.14%) asm: 42 (0.01%) Total Physical Source Lines of Code (SLOC) = 324,319 Development Effort Estimate, Person-Years (Person-Months) = 86.61 (1,039.28) (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05)) Schedule Estimate, Years (Months) = 2.92 (35.02) (Basic COCOMO model, Months = 2.5 * (person-months**0.38)) Estimated Average Number of Developers (Effort/Schedule) = 29.68 Total Estimated Cost to Develop = $ 11,699,374 (average salary = $56,286/year, overhead = 2.40). SLOCCount, Copyright (C) 2001-2004 David A. Wheeler SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL. SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to redistribute it under certain conditions as specified by the GNU GPL license; see the documentation for details. Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."
BohrMe · 367 weeks and 4 days ago
11,699,374 That is a lot of work. Good luck.
RanyAlbeg · 367 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: