Tuesday, August 27, 2019

Comments Analyzer

Simple comment analyzer for bash scripts, hack it and make it your own.
alias comments='_(){ [[ "${1:-0}" =~ ^- ]]&&echo " Usage: comments [<percent greater> <file_filter (e.g. bsh)>]" &&return 1;local pct=${1:-0};local frag=${2};for a in *"${frag}";do awk -v v_PCT=${pct} "{j++;if(\$0 ~ /^#.*/){i++;};}END{if(NR==0){exit 1;};pct=((i/j)*100);if(pct>=v_PCT){print ARGV[1] \" Num comments:\" i \" Total Lines:\" j \" Percent:\" pct;};}"  "${a}";done;};_' 

No comments:

Post a Comment