Quantcast
Viewing all articles
Browse latest Browse all 524

Print data for an object based on value(variable) for a key in jq output [duplicate]

I have this JSON :

[  {"id": "1","agent": "23ef","displayName": "foo.com"  },  {"id": "2","agent": "23gh","displayName": "foo2.com"  },  {"id": "3","agent": "23gf","displayName": "boo.com"  }]

Wanted to get the dataset for all objects which have foo in their displayName.

I am able to get when i pass the value as a string,

$ cat /tmp/z.json | jq -r '.[] | select(.displayName=="foo.com")'  {   "id": "1",   "agent": "23ef",   "displayName": "foo.com" }

But not getting when i try a regex. Can somebody help?

$ cat /tmp/z.json | jq -r '.[] | select(.displayName=="foo*")'

Viewing all articles
Browse latest Browse all 524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>