Initial commit of »various«. - various - Various utilities developed at bitre… | |
git clone git://bitreich.org/various/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinw… | |
Log | |
Files | |
Refs | |
Tags | |
--- | |
commit 0fd0ba5c0a34e5d172dd615379d1dba5a155e4fc | |
Author: Christoph Lohmann <[email protected]> | |
Date: Wed, 4 Jan 2017 21:08:19 +0100 | |
Initial commit of »various«. | |
Diffstat: | |
A linecount | 28 ++++++++++++++++++++++++++++ | |
1 file changed, 28 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/linecount b/linecount | |
@@ -0,0 +1,28 @@ | |
+#!/bin/sh | |
+ | |
+if [ $# -gt 0 ]; | |
+then | |
+ directory="$1" | |
+ shift 1 | |
+else | |
+ printf "usage: %s directory|file ['*.ext']\n" "$(basename "$0")" >&2 | |
+ exit 1 | |
+fi | |
+ | |
+if [ $# -lt 1 ]; | |
+then | |
+ extensions="*" | |
+else | |
+ extensions="$1" | |
+fi | |
+ | |
+if [ -d "${directory}" ]; | |
+then | |
+ find "${directory}" -name "${extensions}" -type f \ | |
+ -exec wc -l {} \; \ | |
+ | awk '{ SUM += $0 } END { print SUM }' | |
+else | |
+ wc -l "${directory}" | cut -d' ' -f 1 | |
+fi | |
+ | |
+ |