Skip to content

Instantly share code, notes, and snippets.

@karanjitsingh
Last active February 8, 2018 20:32
Show Gist options
  • Save karanjitsingh/070e7fdd94ffbda926dff5df8eef69b5 to your computer and use it in GitHub Desktop.
Save karanjitsingh/070e7fdd94ffbda926dff5df8eef69b5 to your computer and use it in GitHub Desktop.
Count your code using shell
# Usage: ./codecount.sh css js html
lines=0
for var in "$@"
do
count=0
count=$( find ./ -regex ".*\.$var" | ( while read line; do
count=`wc -l $line`
count="${count// .*/}"
total=$((count + total + 1))
done; echo $total ) )
if [ "$count" == "" ];then
count=0
fi
lines=$((count + lines))
echo -e "$var\t$count"
done
echo -e "\ntotal\t$lines"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment