linecount - 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 --- linecount (406B) --- 1 #!/bin/sh 2 3 if [ $# -gt 0 ]; 4 then 5 directory="$1" 6 shift 1 7 else 8 printf "usage: %s directory|file ['*.ext']\n" "$(basename "$0")" >&2 9 exit 1 10 fi 11 12 if [ $# -lt 1 ]; 13 then 14 extensions="*" 15 else 16 extensions="$1" 17 fi 18 19 if [ -d "${directory}" ]; 20 then 21 find "${directory}" -name "${extensions}" -type f \ 22 -exec wc -l {} \; \ 23 | awk '{ SUM += $0 } END { print SUM }' 24 else 25 wc -l "${directory}" | cut -d' ' -f 1 26 fi 27 28