afegir opció fitxer resum
This commit is contained in:
parent
8a9f82ca56
commit
80222cd33f
|
@ -1,8 +1,24 @@
|
||||||
#!/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"
|
sites_output="./${!#}_sites.log"
|
||||||
mides_output="./${!#}_mides.log"
|
mides_output="./${!#}_mides.log"
|
||||||
|
resum_output="./${!#}_resum.log"
|
||||||
|
|
||||||
year=$(date +"%Y")
|
year=$(date +"%Y")
|
||||||
|
|
||||||
echo "Analitzant ${!#}..."
|
echo "Analitzant ${!#}..."
|
||||||
|
@ -30,13 +46,16 @@ then
|
||||||
grep -e "--$year" $output | awk '{printf("%s\n", $3)}' | sort | uniq >> $sites_output
|
grep -e "--$year" $output | awk '{printf("%s\n", $3)}' | sort | uniq >> $sites_output
|
||||||
sed -i '$ d' $sites_output
|
sed -i '$ d' $sites_output
|
||||||
sed -i '1d' $sites_output
|
sed -i '1d' $sites_output
|
||||||
echo "## Resum dels fitxers baixats ##"
|
if [ $resum = 1 ]
|
||||||
sleep 1s
|
then
|
||||||
while read line; do
|
echo "## Resum dels fitxers baixats ##"
|
||||||
wget --server-response --no-directories --spider -e robots=off --output-file="$mides_output" "$line"
|
sleep 1s
|
||||||
echo "$line $(grep -e "Content-Length" $mides_output | awk '{printf("%.2fKb\n", $2 / 1024)}')"
|
while read line; do
|
||||||
rm $mides_output
|
wget --server-response --no-directories --spider -e robots=off --output-file="$mides_output" "$line"
|
||||||
done < $sites_output
|
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
|
#grep -e "Content-Length" $output | awk '{printf("%.2fKb\n", $2 / 1024)}' >> $mides_output
|
||||||
# echo "## Resum dels fitxers baixats ##"
|
# echo "## Resum dels fitxers baixats ##"
|
||||||
# sleep 1s
|
# sleep 1s
|
||||||
|
|
Loading…
Reference in New Issue
Block a user