Place Holder Products Code
Bash MySQL
Notes Return of the Fed Login
Admin Control Panel Email Control Panel Product Control Panel Debug Info Beacon Create Snippet Tag Control Panel

Naive Line of Code Count

A quick and dirty LOC approximation based on file extension.

Replace *.php in the example with whatever will match the files you want to line count.

t=0;n=0;find dir-to-search/ -name "*.php" -exec wc -l {} \; > loc.TEMP;  while read l; do n=$(echo -n $l | cut -d" " -f1); t=$((t+n)); done < loc.TEMP; echo "Total Lines: $t"; rm loc.TEMP

This is pretty straightforward.  First, we makes sure our vars are set to zero.

It makes use of find's -exec to run wc, and then sloppily extracts the number of lines with cut.  Then it performs some bash math with the $(()) construct, echos the result and deletes the temporary file.

Finally, it makes use of that great bash while read line; do <stuff> ; done < file while paradigm!

Comments:

No Comments Yet!