Last active
February 8, 2018 20:32
-
-
Save karanjitsingh/070e7fdd94ffbda926dff5df8eef69b5 to your computer and use it in GitHub Desktop.
Count your code using shell
This file contains hidden or 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
# 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