Mazzy
Mazzy

Reputation: 14219

Remove objects from array that match a test against a property

I'd like to remove from an array objects that pass a test against a property'

Assume we have the following array:

[
  {
     "path": "a/b/v1-another"
  },
  {
     "path": "a/b/v1"
  }
]

I'd like to remove from the array the object that match the test a/b/* against path property

Upvotes: 0

Views: 701

Answers (1)

hek2mgl
hek2mgl

Reputation: 158120

Like this:

jq '.[]|select(.path|startswith("a/b/")|not)' file.json

Upvotes: 3

Related Questions