Skip to content

Instantly share code, notes, and snippets.

@m-rey
Created March 21, 2024 13:40
Show Gist options
  • Save m-rey/7b5d794960ccc540b76025aa8b7f6275 to your computer and use it in GitHub Desktop.
Save m-rey/7b5d794960ccc540b76025aa8b7f6275 to your computer and use it in GitHub Desktop.
short one liner to combine Redirector (Firefox extension) rule backups
jq -s '{
"createdAt": (map(select(.createdAt != null) | .createdAt | .[:-5] + "Z" | fromdateiso8601) | max // now | strftime("%Y-%m-%dT%H:%M:%S.000Z")),
"createdBy": (max_by(.createdAt | .[:-5] + "Z" | fromdateiso8601) // {"createdBy": "Redirector"}).createdBy,
"redirects": (map(select(.redirects != null).redirects) | add)
}' Redirector*.json > combined_redirects.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment