Input :
{ "names" : ["name1","name2","name3","pat_name4"] }
Needed output :
{ "names" : ["name1","name2","name3"] }
Currently what i have by running command, to filter out all names starting with pat_
cat file | jq .names | grep -Ev '^(pat_)'
is this
["name1","name2","name3"]
Was wondering if there is some alteration to the jq command that could be done to get in the format needed.
With your input, the invocation:
$ jq -c '.names |= map(select(test("^pat_")|not))'
produces:
{"names":["name1","name2","name3"]}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.