jsmickey jsmickey - 2 years ago 683
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download