From 267a7a6c72d263b290473aea9b096349c6353e87 Mon Sep 17 00:00:00 2001 From: Cheri Dawn Date: Sat, 20 Jul 2024 17:16:53 +0300 Subject: [PATCH] add statistics --- doit | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/doit b/doit index d06ccce..36259b4 100755 --- a/doit +++ b/doit @@ -35,14 +35,35 @@ runsync() { rsync -have ssh $OUTPATH/ $SERVPATH } -while getopts "bcs" flag; do +dostats() { + [ -d $OUTPATH ] + echo -e "Used space:" + echo -e " ├── content: $(du -hs content | cut -f1)" + echo -e " ├── output: $(du -hs $OUTPATH | cut -f1)" + echo -e " └── all: $(du -hs . | cut -f1)" + echo + echo -e "File types:" + echo -e " ├── total: $(find $OUTPATH -type f | wc -l)" + echo -e " ├── total known: $(find $OUTPATH -type f | grep -iE '\.(jpg|png|webp|gif|ico|css|php|html)' | wc -l)" + echo -e " ├── HTML: $(find $OUTPATH -type f -iname '*.html' | wc -l)" + echo -e " ├── CSS: $(find $OUTPATH -type f -iname '*.css' | wc -l)" + echo -e " ├── PHP: $(find $OUTPATH -type f -iname '*.php' | wc -l)" + echo -e " ├── images: $(find $OUTPATH -type f | grep -iE '\.(jpg|png|webp|gif|ico)' | wc -l)" + echo -e " └── other:" + find $OUTPATH -type f | rev | cut -d. -f1 | rev | sort | uniq -c | grep -viE 'html|css|php|jpg|png|webp|gif|ico' | awk '{ print " ├── " $2 ": " $1 }' + echo -e " └── total: $(find $OUTPATH -type f | rev | cut -d. -f1 | rev | sort | grep -viE 'html|php|jpg|png|webp|gif|css|ico' | wc -l)" +} + +while getopts "bcsS" flag; do case ${flag} in b) dobuild=y;; c) doclean=y;; s) dosync=y;; + S) dostats=y;; esac done [ -v doclean ] && rm -rfv output ||: [ -v dobuild ] && runbuild [ -v dosync ] && runsync || true +[ -v dostats ] && dostats