| 1234567891011121314151617 |
- #!/bin/bash
- data=$(</dev/stdin)
- fingerprint=$(echo "$data" | grep -Po '(?<=^extra-info )(.*)(?=$)' | grep -Po '(?<= )(.*)(?=$)')
- date=$(echo "$data" | grep -Po '(?<=^published )(.*)(?= )')
- # Convert to Julian date, thanks to
- # https://stackoverflow.com/a/43318209
- date_julian=$(( $(date +%s -d "${date}") / 86400 + 2440587 ))
- count=$(echo "$data" | grep -Po '(?<=^bridge-ips )(.*)(?=$)' | grep -Po '(?<=by=)(.*?)(?=(,|$))')
- if [ -z "$count" ]; then
- count=0
- fi
- if [[ -n "${date_julian}" && -n "${fingerprint}" ]]; then
- echo "${date_julian},${count}" >> bridge_data/"${fingerprint}"
- fi
|