json – JQ statement simplification

The following command series is used to gather every bit of valuable information from Exodus trackers. The ultimate goal would be to get this all into one jq statement, and if that’s not possible then to just simplify as much as possible.

I’m aware of the sub and gsub functions available in jq, and tried to use them in the statement that parses network signatures. However, operating on the backslashes (even though they were properly escaped) didn’t work, hence the sed cop-out.

Feedback from any angle is welcome!

curl -s 'https://etip.exodus-privacy.eu.org/trackers/export' -o trackers.json

jq -r '.trackers().code_signature | split("|") | reverse | .() | split(".") | reverse | join(".") | ltrimstr(".")' trackers.json >tmp.txt
jq -r '.trackers().network_signature | split("|") | .()' trackers.json | sed -e 's/\././g' -e 's/\//g' -e 's/^.//' >>tmp.txt
jq -r '.trackers().website' trackers.json | mawk -F/ '{print $3}' >>tmp.txt

gawk '/^(((:alnum:)_-){1,63}.)+((:alpha:))+(((:space:))|$)/{print tolower($1)}' tmp.txt >exodus_domains.txt
gawk '/^((0-9){1,3}\.){3}(0-9){1,3}+(\/|:|$)/{sub(/:.*/,"",$3); print $3}' tmp.txt >exodus_ips.txt

rm trackers.json
rm tmp.txt