Skip to content

Instantly share code, notes, and snippets.

@erev0s
Created May 17, 2019 22:04
Show Gist options
  • Save erev0s/653f31bd1f85febed24f2235d0058621 to your computer and use it in GitHub Desktop.
Save erev0s/653f31bd1f85febed24f2235d0058621 to your computer and use it in GitHub Desktop.
extract clean network statistics from firebase after copying them manually from the source of the page
#!/bin/bash
sed "s/<tr>//g" < $1 | sed "s/<\/tr>//g" | sed "s/<td>//g" | sed "s/<\/td>//g" | sed '/^[[:space:]]*$/d' | sed "s/<tbody>//g" | sed "s/<\/tbody>//g" | tr -d '[:blank:]' | tail -n +4 > check
awk '
/[0-9]{2}:[0-9]{2}:[0-9]{2}\.*/ {
if (NR > 1) p()
a[i = 1] = $0
next
}
{ a[++i] = $0 }
END { p() }
function p() {
if (a[2] || a[3]) {
print a[1]
print a[2]
print a[3]
}
delete a
}' check > step1
awk -F, 'length($1) > 8 { print}' < step1 | sed "s/00://g" > nettimes.txt
awk -F, 'length($1) < 8 { print}' < step1 > step2
awk 'NR % 2 == 0' < step2 > sent.txt
awk 'NR % 2 == 1' < step2 > received.txt
rm -f check step1 step2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment