31 lines
600 B
Bash
Executable File
31 lines
600 B
Bash
Executable File
#!/bin/bash
|
|
|
|
output="/tmp/website-size.out"
|
|
echo "Analitzant ${!#}..."
|
|
sleep 1s
|
|
echo "Pot tardar una estona..."
|
|
|
|
wget \
|
|
--recursive --level=1 \
|
|
--spider --server-response \
|
|
--no-directories --no-parent \
|
|
--output-file="$output" "$@"
|
|
|
|
sleep 1s
|
|
if [ -f "$output" ]
|
|
then
|
|
# Calculate and print estimated website size
|
|
echo "Mida estimada de ${!#}: $(\
|
|
grep -e "Content-Length" "$output" | \
|
|
awk '{sum+=$2} END {printf("%.0f", sum / 1024)}'\
|
|
) kb"
|
|
|
|
# Delete wget output file
|
|
rm "$output"
|
|
else
|
|
echo "Unable to calculate estimated size."
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|