Skip to content

Instantly share code, notes, and snippets.

@ps-przemekaugustyn
Created January 20, 2021 20:11
Show Gist options
  • Save ps-przemekaugustyn/3f22dc462d82e667964eea1e05303ccd to your computer and use it in GitHub Desktop.
Save ps-przemekaugustyn/3f22dc462d82e667964eea1e05303ccd to your computer and use it in GitHub Desktop.
Extract from JSON (JQ)
#!/bin/bash
# epoch as a filename
startf=$(basename -- $1)
# convert back to time
starttime=$(date -j -r "${startf%.*}")
endf=$(basename -- $2)
endtime=$(date -j -r "${endf%.*}")
echo from: $starttime
echo to: $endtime
# extract from JSON
startcount=$(cat $startf |jq -r '.data.sources[0].results_count_all')
endcount=$(cat $endf|jq -r '.data.sources[0].results_count_all')
echo $startcount $endcount
echo overall requests $((endcount-startcount))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment