Skip to content

Instantly share code, notes, and snippets.

@andrewpsp
Forked from ipbastola/jq to filter by value.md
Created September 9, 2019 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewpsp/4dd74daab60a5e9de90b04d1b4f3dc9c to your computer and use it in GitHub Desktop.
Save andrewpsp/4dd74daab60a5e9de90b04d1b4f3dc9c to your computer and use it in GitHub Desktop.
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment