Initial commit of »various«. - various - Various utilities developed at bitreich. HTML git clone git://bitreich.org/various/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/various/ DIR Log DIR Files DIR Refs DIR Tags --- DIR commit 0fd0ba5c0a34e5d172dd615379d1dba5a155e4fc HTML Author: Christoph Lohmann <20h@r-36.net> Date: Wed, 4 Jan 2017 21:08:19 +0100 Initial commit of »various«. Diffstat: A linecount | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+), 0 deletions(-) --- DIR 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 + +