Skip to content

Instantly share code, notes, and snippets.

@koniu
Created May 20, 2016 14:15
Show Gist options
  • Save koniu/95cb7666f4fa04f574ddd5927b526a4a to your computer and use it in GitHub Desktop.
Save koniu/95cb7666f4fa04f574ddd5927b526a4a to your computer and use it in GitHub Desktop.
Calculate comment density of shell scripts in a directory
dir=/rom; a=$(find $dir -name \*.sh -exec cat '{}' \; | egrep -cv '^[[:space:]]*#'); b=$(find $dir -name \*.sh -exec cat '{}' \; | egrep -c '^[[:space:]]*#'); echo "$((a+b)) lines = ${a} sloc [$((a*100/(a+b)))%] + ${b} comments [$((b*100/(a+b)))%]"
# 7882 lines = 7576 sloc [96%] + 306 comments [3%]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment