Skip to content

Instantly share code, notes, and snippets.

@ipbastola
Last active September 4, 2025 02:27

Revisions

  1. ipbastola revised this gist Oct 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jq to filter by value.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ## JQ to filter JSON by value
    Syntax: <strong>cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'</strong>
    Syntax: <strong>`cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'`</strong>

    Example: To get json record having _id equal 611
    ```bash
  2. ipbastola revised this gist Oct 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jq to filter by value.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ## JQ to filter JSON by value
    Syntax: *cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'*
    Syntax: <strong>cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'</strong>

    Example: To get json record having _id equal 611
    ```bash
  3. ipbastola created this gist Oct 24, 2016.
    8 changes: 8 additions & 0 deletions jq to filter by value.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    ## JQ to filter JSON by value
    Syntax: *cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'*

    Example: To get json record having _id equal 611
    ```bash
    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)`