使用JQ从Docker Hub获取最新有效的MySQL标签
我正在使用以下命令从Docker Hub上的MySQL获取所有发行标签:
wget -q https://registry.hub.docker.com/v1/repositories/mysql/tags -O - | jq -r .[].name
输出是:
5.7.38
5.7.38-debian
5.7.38-oracle
5.7.4
5.7.4-m14
5.7.5
5.7.5-m15
5.7.6
5.7.6-m16
5.7.7
5.7.7-rc
5.7.8
5.7.8-rc
5.7.9
8
8-debian
8-oracle
8.0
8.0-debian
8.0-oracle
8.0.0
8.0.1
8.0.11
8.0.12
8.0.13
8.0.14
8.0.15
8.0.16
8.0.17
8.0.18
8.0.19
8.0.2
8.0.20
8.0.21
8.0.22
8.0.23
8.0.24
8.0.25
8.0.26
8.0.27
8.0.28
8.0.28-debian
8.0.28-oracle
8.0.29
8.0.29-debian
8.0.29-oracle
8.0.3
8.0.4
8.0.4-rc
debian
oracle
有没有一种方法可以获取最新的稳定版本?例如,我想获取8.0.29,因为它是8倍版本的最新稳定版本。下次,当8.0.30到来时,我从同一命令中获得输出?
任何人都可以帮我或指向正确的方向吗?我尝试使用Xidel,但找不到解决方案
I am using following command to fetch all release tags from mysql on docker hub :
wget -q https://registry.hub.docker.com/v1/repositories/mysql/tags -O - | jq -r .[].name
Output is:
5.7.38
5.7.38-debian
5.7.38-oracle
5.7.4
5.7.4-m14
5.7.5
5.7.5-m15
5.7.6
5.7.6-m16
5.7.7
5.7.7-rc
5.7.8
5.7.8-rc
5.7.9
8
8-debian
8-oracle
8.0
8.0-debian
8.0-oracle
8.0.0
8.0.1
8.0.11
8.0.12
8.0.13
8.0.14
8.0.15
8.0.16
8.0.17
8.0.18
8.0.19
8.0.2
8.0.20
8.0.21
8.0.22
8.0.23
8.0.24
8.0.25
8.0.26
8.0.27
8.0.28
8.0.28-debian
8.0.28-oracle
8.0.29
8.0.29-debian
8.0.29-oracle
8.0.3
8.0.4
8.0.4-rc
debian
oracle
Is there a way i can fetch the latest stable version only? For example , i want to fetch 8.0.29 as it is the latest stable version for 8x version . And next time when 8.0.30 comes i get the output from the same command?
Can anybody please help or point me to right direction? I tried using xidel but could not find solution
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
扫描提取任何数字序列(“ \\ d+”)
,使用tonumber
将字符串转换为数字,并将其用作sort_by 在初始数组上,您可以从中使用索引
-1
从中输出最后一个项目。demo
如果对于输出,您只需要纯版本号/code>而不是
8.0.29-Oracle
),在之后和包括仪表板之后放弃所有内容:演示
Extract any sequence of digits using
scan("\\d+")
, convert the strings to numbers usingtonumber
, and use that as argument forsort_by
on the initial array, from which you can then output the last item using index-1
.Demo
If for the output you only want the pure version number (
8.0.29
instead of8.0.29-oracle
), ditch everything after and including the dash sign:Demo
如果您仍然有兴趣,这并不难:
[artees(。 )]
仅返回这些名称
仅使用数字。按$ x
进行排序订单。(
...)[last()]
返回序列的最后一项(在这种情况下为最新版本)。或者,您可以使用
max()
:If you're still interested, it's not that hard:
[matches(.,"^\d+\.\d+\.\d+$")]
returns only thosename
s with just digits.order by $x
for sorting.(
...)[last()]
to return the last item of the sequence (in this case the latest version).Alternatively and even shorter, you can use
max()
:最新版本具有
最新
标签。 “稳定”是在情人眼中,而不是通过给定信息来计算的。The latest version has the
latest
tag. "stable" is in the eye of the beholder and not computable with the given information.