Quantcast
Channel: A Portal to a Portal
Viewing all articles
Browse latest Browse all 1850

Munging JSON with JQ - without using grep and awk

$
0
0

Further to a previous post: -

Grep AND awk

I wanted to achieve much the same, but only using jq

So here we go: -

c is images --output JSON | jq -r '.[] | {Name:.name,Architecture:.operating_system.architecture,Status:.status} | select((.Name | contains("ubuntu")) and (.Architecture | startswith("s390x")) and (.Status | startswith("available")))'

which returns: -

{
  "Name": "ibm-ubuntu-18-04-1-minimal-s390x-3",
  "Architecture": "s390x",
  "Status": "available"
}

as opposed to the alternative: -

ic is images | awk '/s390x/ && /ubuntu/ && /available/'

r018-e3d94080-972f-4f18-8a79-60a12d0b61c2   ibm-ubuntu-18-04-1-minimal-s390x-3                 available    s390x   ubuntu-18-04-s390x                   18.04 LTS Bionic Beaver Minimal Install   2               public       provider     none         -   


Viewing all articles
Browse latest Browse all 1850

Trending Articles



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