Skip to content

Instantly share code, notes, and snippets.

@mherwig
Last active May 19, 2020 22:56
Show Gist options
  • Save mherwig/4133244 to your computer and use it in GitHub Desktop.
Save mherwig/4133244 to your computer and use it in GitHub Desktop.
Shell script for counting the total physical source lines of code (LOC)
#!/bin/bash
#
# Author: Mike Herwig
# Description:
# Shell script for counting the total physical source lines of code (LOC)
#
# example: ./LOC.sh java h cpp xml
ARG_COUNT=1
for ARG in $*; do
if [ $ARG_COUNT -gt 1 ]; then
find $1 -name "*.$ARG" -exec loc_helper.sh {} \;
fi
ARG_COUNT=$(( $ARG_COUNT + 1 ))
done
echo "The total physical source lines of code (LOC) are " $(cat .loc.tmp)
rm .loc.tmp
#!/bin/bash
if [ -f .loc.tmp ]; then
NUM=`cat .loc.tmp`
else
NUM=0
fi
NUM_CUR=`wc -l $1 | cut -f1 -d" "`
NUM=$(( $NUM + $NUM_CUR ))
echo $NUM > .loc.tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment