jsmickey jsmickey - 1 year ago 548
JSON Question

Json JQ Filter with Wildcard in Bash

Json input:

[ "orange-1234", "orange-12345", "apple-1234" ]

Desired output:

[ "orange-1234, "orange-12345" ]

Via bash, I would like to use jq to find the values starting or containing orange*

I would like the output to contain the complete value. I have explored using jq startswith and contains, but only was able to return true or false

Answer Source

As of jq 1.5, you could do regular expression matching. So with that, just filter your array.