Compare commits
No commits in common. "80222cd33f886bdb7e5ea3178d8b9d82de8cd2cf" and "cfcd4d55908b8e724dfb49c497e85a90212e0b0b" have entirely different histories.
80222cd33f
...
cfcd4d5590
|
@ -1,30 +1,9 @@
|
||||||
#!/bin/bash
|
#!/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"
|
output="./${!#}.log"
|
||||||
sites_output="./${!#}_sites.log"
|
|
||||||
mides_output="./${!#}_mides.log"
|
|
||||||
resum_output="./${!#}_resum.log"
|
|
||||||
|
|
||||||
year=$(date +"%Y")
|
|
||||||
|
|
||||||
echo "Analitzant ${!#}..."
|
echo "Analitzant ${!#}..."
|
||||||
sleep 1s
|
sleep 1s
|
||||||
echo "Pot tardar una estona..."
|
echo "Pot tardar una estona..."
|
||||||
echo ""
|
|
||||||
|
|
||||||
wget \
|
wget \
|
||||||
--recursive --level=1 \
|
--recursive --level=1 \
|
||||||
|
@ -41,28 +20,9 @@ then
|
||||||
grep -e "Content-Length" "$output" | \
|
grep -e "Content-Length" "$output" | \
|
||||||
awk '{sum+=$2} END {printf("%.0f", sum / 1024)}'\
|
awk '{sum+=$2} END {printf("%.0f", sum / 1024)}'\
|
||||||
) kb"
|
) kb"
|
||||||
echo ""
|
|
||||||
sleep 1s
|
|
||||||
grep -e "--$year" $output | awk '{printf("%s\n", $3)}' | sort | uniq >> $sites_output
|
|
||||||
sed -i '$ d' $sites_output
|
|
||||||
sed -i '1d' $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
|
|
||||||
#echo "$(paste $sites_output $mides_output | uniq)"
|
|
||||||
# Delete wget output file
|
# Delete wget output file
|
||||||
rm "$output"
|
rm "$output"
|
||||||
rm "$sites_output"
|
|
||||||
else
|
else
|
||||||
echo "Unable to calculate estimated size."
|
echo "Unable to calculate estimated size."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user