# count relays
grep -c "^r " 2020-07-01-01-00-00-consensus

# count relays with IPv6 ORPort
grep -c "^a \[" 2020-07-01-01-00-00-consensus

# compute total consensus weight
grep "^w " 2020-07-01-01-00-00-consensus | cut -d"=" -f2 | awk '{s+=$1}END{print s}'

# compute consensus weight of relays with IPv6 ORPort
grep -A5 "^a \[" 2020-07-01-01-00-00-consensus | grep "^w " | cut -d"=" -f2 | awk '{s+=$1}END{print s}'

# count relays with IPv6 ORPort and partial IPv6 reachability checks
grep -A5 "^a \[" 2020-07-01-01-00-00-consensus | grep "^v Tor 0.4.4.[1-9]" | sort | uniq -c

# count relays with IPv6 ORPort and full IPv6 reachability checks
grep -A5 "^a \[" 2020-07-01-01-00-00-consensus | grep -B1 "^pr.* Relay=..3" | grep "^v Tor 0.4.5" | sort | uniq -c

# compute consensus weight of relays with IPv6 ORPort and partial IPv6 reachability checks
grep -A5 "^a \[" 2020-07-01-01-00-00-consensus | grep -A2 "^v Tor 0.4.4.[1-9]" | grep "^w " | cut -d"=" -f2 | awk '{s+=$1}END{print s}'

# compute consensus weight of relays with IPv6 ORPort and full IPv6 reachability checks
grep -A5 "^a \[" 2020-07-01-01-00-00-consensus | grep -C1 "^pr.* Relay=..3" | grep -A2 "^v Tor 0.4.5" | grep "^w " | cut -d"=" -f2 | awk '{s+=$1}END{print s}'

# obtain subset of usable guards
grep -v "^s.* Exit" 2020-07-01-01-00-00-consensus | grep -B2 -A4 "^s.* Guard" > 2020-07-01-01-00-00-usable-guards
grep -B2 -A4 "^s.* BadExit.* Guard" 2020-07-01-01-00-00-consensus >> 2020-07-01-01-00-00-usable-guards

# count usable guards
grep -c "^r " 2020-07-01-01-00-00-usable-guards

# find Wgd value
grep Wgd 2020-07-01-01-00-00-consensus

# count usable guards with IPv6 ORPort
grep -c "^a \[" 2020-07-01-01-00-00-usable-guards

# compute usable guards consensus weight
grep "^w " 2020-07-01-01-00-00-usable-guards | cut -d"=" -f2 | awk '{s+=$1}END{print s}'

# compute consensus weight of usable guards with IPv6 ORPort
grep -A5 "^a \[" 2020-07-01-01-00-00-usable-guards | grep "^w " | cut -d"=" -f2 | awk '{s+=$1}END{print s}'

# count usable guards with IPv6 ORPort and partial IPv6 reachability checks
grep -A5 "^a \[" 2020-07-01-01-00-00-usable-guards | grep "^v Tor 0.4.4.[1-9]" | sort | uniq -c

# count usable guards with IPv6 ORPort and full IPv6 reachability checks
grep -A5 "^a \[" 2020-07-01-01-00-00-usable-guards | grep -C1 "^pr.* Relay=..3" | grep "^v Tor 0.4.5" | sort | uniq -c

# compute consensus weight of usable guards with IPv6 ORPort and partial IPv6 reachability checks
grep -A5 "^a \[" 2020-07-01-01-00-00-usable-guards | grep -A2 "^v Tor 0.4.4.[1-9]" | grep "^w " | cut -d"=" -f2 | awk '{s+=$1}END{print s}'

# compute consensus weight of usable guards with IPv6 ORPort and full IPv6 reachability checks
grep -A5 "^a \[" 2020-07-01-01-00-00-usable-guards | grep -C1 "^pr.* Relay=..3" | grep -A2 "^v Tor 0.4.5" | grep "^w " | cut -d"=" -f2 | awk '{s+=$1}END{print s}'

