Skip to content

Instantly share code, notes, and snippets.

@ahmetb
Created February 17, 2013 22:21
Show Gist options
  • Save ahmetb/4973807 to your computer and use it in GitHub Desktop.
Save ahmetb/4973807 to your computer and use it in GitHub Desktop.
Quick SLoC counter in CLI
# Counts source lines of code in current directory. Replace *.java with your source extension.
# (ignores empty lines)
find . -type f -name '*.java' -exec cat {} \; | sed '/^\s*$/d' | wc -l
# to ignore comments (in languages where comments start with #)
find . -type f -name '*.java' -exec cat {} \; | sed '/^\s*#/d;/^\s*$/d' | wc -l
@ahmetb
Copy link
Author

ahmetb commented Mar 13, 2013

In most package managers (apt, brew etc) there is sloccount package. It gives detailed stats, you better use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment