Created
April 26, 2011 15:11
-
-
Save thefotios/942458 to your computer and use it in GitHub Desktop.
This is a way to count lines in JavaScript files. It will count the comments (multiline with /*, *, and */ as well as single line //). It then outputs the number of lines, number of comment lines, and number of code lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf "%25s %6s %6s %10s\n" "Filename" "Lines" "Code" "Comments" && \ | |
find -name "*.js" -exec awk ' \ | |
/^[ \t]*([\/]*\*|\/\/)/ {comments++} \ | |
/^[ \t]*$/ {blank++} \ | |
END{printf "%25s %6s %6s %10s\n",FILENAME,FNR,FNR-comments-blank,comments} \ | |
' {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment