Refactoring stat.sh

This commit is contained in:
Yifan Gao 2019-12-19 14:47:56 +08:00
parent c74585c9f5
commit eeae995e4e

21
stat.sh
View File

@ -5,31 +5,22 @@ cd result
for file in *.txt; do
echo ${file%.*}
if [[ $file == *6.txt ]]; then
cat $file |
awk -F\/ '{print $2}' |
(
sum=0
while read n; do
if [[ -n $n ]]; then
((s=64-n))
((sum+=1<<s))
fi
done
echo $sum
)
#statistics IPv6 /48 blocks
base=48
else
base=32
fi
cat $file |
awk -F\/ '{print $2}' |
(
sum=0
while read n; do
if [[ -n $n ]]; then
((s=32-n))
if [[ -n $n ]] && [[ $n -le $base ]]; then
((s=base-n))
((sum+=1<<s))
fi
done
echo $sum
)
fi
echo
done | tee stat