linecount/linecount

20 lines
476 B
Bash

#! /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