diff --git a/linecount b/linecount new file mode 100644 index 0000000..a1a44ba --- /dev/null +++ b/linecount @@ -0,0 +1,19 @@ +#! /usr/bin/env sh + +### +# Counts the lines of text in the specified files/directories +### + +echo "Counting lines in '$(find "$@" -maxdepth 0)'" + +n=0 +find "$@" -exec wc -l {} \; 2>/dev/null | while true; do + if read line; then + n=$["$n" + "$(echo "$line" | cut -d" " -f1)"] + n_human_readable="$(echo "$n" | numfmt --to=si --round=nearest)" + printf "\e[2KLines: %s (counting)\r" "$n_human_readable" + else + printf "\e[2KLines: %s\r\n" "$n_human_readable" + break + fi +done