Last active
May 19, 2020 22:56
-
-
Save mherwig/4133244 to your computer and use it in GitHub Desktop.
Shell script for counting the total physical source lines of code (LOC)
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
#!/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 |
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
#!/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