From a84751d79c5c6e26d4a13033e32719a2d9729d91 Mon Sep 17 00:00:00 2001 From: r4 Date: Thu, 1 Apr 2021 19:09:30 +0000 Subject: [PATCH] Upload files to '' --- linecount | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 linecount 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