Add a simple code lines counter
authorBenjamin Auder <benjamin.auder@somewhere>
Fri, 21 Dec 2018 22:24:29 +0000 (23:24 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Fri, 21 Dec 2018 22:24:29 +0000 (23:24 +0100)
countLines.sh [new file with mode: 0755]

diff --git a/countLines.sh b/countLines.sh
new file mode 100755 (executable)
index 0000000..3de4304
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+# Count code lines ( using answer https://stackoverflow.com/a/965072 )
+
+function countFoldExt()
+{
+       count=0
+       for fullfile in `find $1`; do
+               filename=$(basename -- "$fullfile")
+               extension="${filename##*.}"
+               if [ "$extension" == "$2" ]; then
+                       count=$((count+`wc -l $fullfile | grep -o ^[0-9]*`))
+               fi
+       done
+       echo $count
+}
+
+count=0
+count=$((count + $(countFoldExt "app.js" "js")))
+count=$((count + $(countFoldExt "gulpfile.js" "js")))
+count=$((count + $(countFoldExt "sockets.js" "js")))
+count=$((count + $(countFoldExt "bin" "www")))
+count=$((count + $(countFoldExt "db" "sql")))
+count=$((count + $(countFoldExt "public" "js")))
+count=$((count + $(countFoldExt "public" "sass")))
+count=$((count + $(countFoldExt "routes" "js")))
+count=$((count + $(countFoldExt "views" "pug")))
+echo $count