How to parse json output and compare it with a standard input value?
by sysmicuser from LinuxQuestions.org on (#4WY34)
I run the following command
Code:wget https://registry.access.redhat.com/v2/rhel7/tags/list -O -I get the below output:
Code:--2019-12-22 12:20:32-- https://registry.access.redhat.com/v2/rhel7/tags/list
Resolving registry.access.redhat.com (registry.access.redhat.com)... 104.116.133.103
Connecting to registry.access.redhat.com (registry.access.redhat.com)|104.116.133.103|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://registry.access.redhat.com/webassets/docker/content/dist/rhel/server/7/7Server/multiarch/containers/registry/redhat-rhel7/tags/list [following]
--2019-12-22 12:20:32-- https://registry.access.redhat.com/webassets/docker/content/dist/rhel/server/7/7Server/multiarch/containers/registry/redhat-rhel7/tags/list
Reusing existing connection to registry.access.redhat.com:443.
HTTP request sent, awaiting response... 200 OK
Length: 839 [text/plain]
Saving to: 'STDOUT'
0% [ ] 0 --.-K/s {"name": "rhel7", "tags": ["7.3-74", "7.4-120", "7.2-56", "7.3-89", "7.3-66", "7.5-424", "7.5-245.1527091554", "7.4-129", "7.1-12", "7.6-122", "7.3-82", "7.7-384.1575996163", "7.5-409.1533127727", "7.2-75", "7.2-38", "7.6", "7.7-348", "7.4", "7.5", "7.6-301.1561066494", "7.4-164", "7.7", "7.1-24", "7.2-35", "7.7-269", "7.1-6", "7.6-122.1547747894", "7.5-231", "7.5-404", "7.1-9", "7.4-81", "7.6-362", "7.6-252", "7.6-202.1553789841", "7.2-104", "7.3-97", "7.4-113", "7.7-384", "7.6-119", "7.1-16", "7.1-4", "7.6-301", "7.5-433", "7.0-27", "7.3-95", "7.6-115", "7.3-79", "7.0-21", "7.4-152", "7.7-310", "7.5-245", "7.6-252.1561619826", "7.3-53", "7.0-23", "7.6-151.1550575774", "7.3", "7.2", "7.4-105", "7.6-202.1554729462", "7.3-45", "7.5-409", "7.2-46", "7.6-151", "7.2-44", "7.2-43", "7.1-11", "7.2-61", "latest", "7100%[===========================================================================>] 839 --.-K/s in 0s
2019-12-22 12:20:32 (134 MB/s) - written to stdout [839/839]What I do care is about these values
Code:["7.3-74", "7.4-120", "7.2-56", "7.3-89", "7.3-66", "7.5-424", "7.5-245.1527091554", "7.4-129", "7.1-12", "7.6-122", "7.3-82", "7.7-384.1575996163", "7.5-409.1533127727", "7.2-75", "7.2-38", "7.6", "7.7-348", "7.4", "7.5", "7.6-301.1561066494", "7.4-164", "7.7", "7.1-24", "7.2-35", "7.7-269", "7.1-6", "7.6-122.1547747894", "7.5-231", "7.5-404", "7.1-9", "7.4-81", "7.6-362", "7.6-252", "7.6-202.1553789841", "7.2-104", "7.3-97", "7.4-113", "7.7-384", "7.6-119", "7.1-16", "7.1-4", "7.6-301", "7.5-433", "7.0-27", "7.3-95", "7.6-115", "7.3-79", "7.0-21", "7.4-152", "7.7-310", "7.5-245", "7.6-252.1561619826", "7.3-53", "7.0-23", "7.6-151.1550575774", "7.3", "7.2", "7.4-105", "7.6-202.1554729462", "7.3-45", "7.5-409", "7.2-46", "7.6-151", "7.2-44", "7.2-43", "7.1-11", "7.2-61", "latest", "7xxxxxxxxxxxxxxxxxxwhere
xxxxxxxx denotes the values which are truncated in output.
Actual entire output when I just run wget without- O - is below
Code:{"name": "rhel7", "tags": ["7.3-74", "7.4-120", "7.2-56", "7.3-89", "7.3-66", "7.5-424", "7.5-245.1527091554", "7.4-129", "7.1-12", "7.6-122", "7.3-82", "7.7-384.1575996163", "7.5-409.1533127727", "7.2-75", "7.2-38", "7.6", "7.7-348", "7.4", "7.5", "7.6-301.1561066494", "7.4-164", "7.7", "7.1-24", "7.2-35", "7.7-269", "7.1-6", "7.6-122.1547747894", "7.5-231", "7.5-404", "7.1-9", "7.4-81", "7.6-362", "7.6-252", "7.6-202.1553789841", "7.2-104", "7.3-97", "7.4-113", "7.7-384", "7.6-119", "7.1-16", "7.1-4", "7.6-301", "7.5-433", "7.0-27", "7.3-95", "7.6-115", "7.3-79", "7.0-21", "7.4-152", "7.7-310", "7.5-245", "7.6-252.1561619826", "7.3-53", "7.0-23", "7.6-151.1550575774", "7.3", "7.2", "7.4-105", "7.6-202.1554729462", "7.3-45", "7.5-409", "7.2-46", "7.6-151", "7.2-44", "7.2-43", "7.1-11", "7.2-61", "latest", "7.2-84", "7.6-202"]}My goal is to get values higher than any specified value.
Example, input could be 7.7-348, and hence output should be 7.7-384 and 7.7-384.1575996163. But the value should 7.7-384.1575996163 should be come as a recommended values as its greatest in the array.
How to achieve this easily? Shell script or python? Anyone can guide me, please.
Thank you in advance.


Code:wget https://registry.access.redhat.com/v2/rhel7/tags/list -O -I get the below output:
Code:--2019-12-22 12:20:32-- https://registry.access.redhat.com/v2/rhel7/tags/list
Resolving registry.access.redhat.com (registry.access.redhat.com)... 104.116.133.103
Connecting to registry.access.redhat.com (registry.access.redhat.com)|104.116.133.103|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://registry.access.redhat.com/webassets/docker/content/dist/rhel/server/7/7Server/multiarch/containers/registry/redhat-rhel7/tags/list [following]
--2019-12-22 12:20:32-- https://registry.access.redhat.com/webassets/docker/content/dist/rhel/server/7/7Server/multiarch/containers/registry/redhat-rhel7/tags/list
Reusing existing connection to registry.access.redhat.com:443.
HTTP request sent, awaiting response... 200 OK
Length: 839 [text/plain]
Saving to: 'STDOUT'
0% [ ] 0 --.-K/s {"name": "rhel7", "tags": ["7.3-74", "7.4-120", "7.2-56", "7.3-89", "7.3-66", "7.5-424", "7.5-245.1527091554", "7.4-129", "7.1-12", "7.6-122", "7.3-82", "7.7-384.1575996163", "7.5-409.1533127727", "7.2-75", "7.2-38", "7.6", "7.7-348", "7.4", "7.5", "7.6-301.1561066494", "7.4-164", "7.7", "7.1-24", "7.2-35", "7.7-269", "7.1-6", "7.6-122.1547747894", "7.5-231", "7.5-404", "7.1-9", "7.4-81", "7.6-362", "7.6-252", "7.6-202.1553789841", "7.2-104", "7.3-97", "7.4-113", "7.7-384", "7.6-119", "7.1-16", "7.1-4", "7.6-301", "7.5-433", "7.0-27", "7.3-95", "7.6-115", "7.3-79", "7.0-21", "7.4-152", "7.7-310", "7.5-245", "7.6-252.1561619826", "7.3-53", "7.0-23", "7.6-151.1550575774", "7.3", "7.2", "7.4-105", "7.6-202.1554729462", "7.3-45", "7.5-409", "7.2-46", "7.6-151", "7.2-44", "7.2-43", "7.1-11", "7.2-61", "latest", "7100%[===========================================================================>] 839 --.-K/s in 0s
2019-12-22 12:20:32 (134 MB/s) - written to stdout [839/839]What I do care is about these values
Code:["7.3-74", "7.4-120", "7.2-56", "7.3-89", "7.3-66", "7.5-424", "7.5-245.1527091554", "7.4-129", "7.1-12", "7.6-122", "7.3-82", "7.7-384.1575996163", "7.5-409.1533127727", "7.2-75", "7.2-38", "7.6", "7.7-348", "7.4", "7.5", "7.6-301.1561066494", "7.4-164", "7.7", "7.1-24", "7.2-35", "7.7-269", "7.1-6", "7.6-122.1547747894", "7.5-231", "7.5-404", "7.1-9", "7.4-81", "7.6-362", "7.6-252", "7.6-202.1553789841", "7.2-104", "7.3-97", "7.4-113", "7.7-384", "7.6-119", "7.1-16", "7.1-4", "7.6-301", "7.5-433", "7.0-27", "7.3-95", "7.6-115", "7.3-79", "7.0-21", "7.4-152", "7.7-310", "7.5-245", "7.6-252.1561619826", "7.3-53", "7.0-23", "7.6-151.1550575774", "7.3", "7.2", "7.4-105", "7.6-202.1554729462", "7.3-45", "7.5-409", "7.2-46", "7.6-151", "7.2-44", "7.2-43", "7.1-11", "7.2-61", "latest", "7xxxxxxxxxxxxxxxxxxwhere
xxxxxxxx denotes the values which are truncated in output.
Actual entire output when I just run wget without- O - is below
Code:{"name": "rhel7", "tags": ["7.3-74", "7.4-120", "7.2-56", "7.3-89", "7.3-66", "7.5-424", "7.5-245.1527091554", "7.4-129", "7.1-12", "7.6-122", "7.3-82", "7.7-384.1575996163", "7.5-409.1533127727", "7.2-75", "7.2-38", "7.6", "7.7-348", "7.4", "7.5", "7.6-301.1561066494", "7.4-164", "7.7", "7.1-24", "7.2-35", "7.7-269", "7.1-6", "7.6-122.1547747894", "7.5-231", "7.5-404", "7.1-9", "7.4-81", "7.6-362", "7.6-252", "7.6-202.1553789841", "7.2-104", "7.3-97", "7.4-113", "7.7-384", "7.6-119", "7.1-16", "7.1-4", "7.6-301", "7.5-433", "7.0-27", "7.3-95", "7.6-115", "7.3-79", "7.0-21", "7.4-152", "7.7-310", "7.5-245", "7.6-252.1561619826", "7.3-53", "7.0-23", "7.6-151.1550575774", "7.3", "7.2", "7.4-105", "7.6-202.1554729462", "7.3-45", "7.5-409", "7.2-46", "7.6-151", "7.2-44", "7.2-43", "7.1-11", "7.2-61", "latest", "7.2-84", "7.6-202"]}My goal is to get values higher than any specified value.
Example, input could be 7.7-348, and hence output should be 7.7-384 and 7.7-384.1575996163. But the value should 7.7-384.1575996163 should be come as a recommended values as its greatest in the array.
How to achieve this easily? Shell script or python? Anyone can guide me, please.
Thank you in advance.