From 73564bf6340694c2e8a67a7c57334da5c1c23a73 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Fri, 21 Dec 2018 23:24:29 +0100 Subject: [PATCH] Add a simple code lines counter --- countLines.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 countLines.sh diff --git a/countLines.sh b/countLines.sh new file mode 100755 index 00000000..3de43049 --- /dev/null +++ b/countLines.sh @@ -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 -- 2.44.0