From 80222cd33f886bdb7e5ea3178d8b9d82de8cd2cf Mon Sep 17 00:00:00 2001 From: Xaloc Date: Tue, 23 Jan 2024 15:05:05 +0100 Subject: [PATCH] =?UTF-8?q?afegir=20opci=C3=B3=20fitxer=20resum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- website-size.sh | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/website-size.sh b/website-size.sh index b8452f2..a1c9616 100755 --- a/website-size.sh +++ b/website-size.sh @@ -1,8 +1,24 @@ #!/bin/bash +resum=0 +while getopts 'r:' OPTION; do + case "$OPTION" in + r) + resum=1 + ;; + ?) + echo "utilització: ./website-size.sh [-r (crear un fitxer resum)] example.org" >&2 + exit 1 + ;; + esac +done +# shift "$(($OPTIND -1))" + output="./${!#}.log" sites_output="./${!#}_sites.log" mides_output="./${!#}_mides.log" +resum_output="./${!#}_resum.log" + year=$(date +"%Y") echo "Analitzant ${!#}..." @@ -30,13 +46,16 @@ then grep -e "--$year" $output | awk '{printf("%s\n", $3)}' | sort | uniq >> $sites_output sed -i '$ d' $sites_output sed -i '1d' $sites_output - echo "## Resum dels fitxers baixats ##" - sleep 1s - while read line; do - wget --server-response --no-directories --spider -e robots=off --output-file="$mides_output" "$line" - echo "$line $(grep -e "Content-Length" $mides_output | awk '{printf("%.2fKb\n", $2 / 1024)}')" - rm $mides_output - done < $sites_output + if [ $resum = 1 ] + then + echo "## Resum dels fitxers baixats ##" + sleep 1s + while read line; do + wget --server-response --no-directories --spider -e robots=off --output-file="$mides_output" "$line" + echo "$line $(grep -e "Content-Length" $mides_output | awk '{printf("%.2fKb\n", $2 / 1024)}')" + rm $mides_output + done < $sites_output >> $resum_output + fi #grep -e "Content-Length" $output | awk '{printf("%.2fKb\n", $2 / 1024)}' >> $mides_output # echo "## Resum dels fitxers baixats ##" # sleep 1s