用于对 debian 版本号进行排序的 Shell 脚本 (line_5.4.3-2) [英] Shell script to sort debian version numbers (line_5.4.3-2)

查看:19
本文介绍了用于对 debian 版本号进行排序的 Shell 脚本 (line_5.4.3-2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本文件,其中的条目表示带有版本和内部版本号的构建标签,格式与 debian 软件包相同,如下所示:

I have a text file with entries representing build tags with version and build number in the same format as debian packages like this:

nimbox-apexer_1.0.0-12
nimbox-apexer_1.1.0-2
nimbox-apexer_1.1.0-1
nimbox-apexer_1.0.0-13 

使用 shell 脚本,我需要按 'version-build' 对上面的列表进行排序并得到最后一行,在上面的例子中是 nimbox-apexer_1.1.0-2.

Using a shell script I need to sort the above list by 'version-build' and get the last line, which in the above example is nimbox-apexer_1.1.0-2.

推荐答案

获取最新版本:

cat file.txt | sort -V | tail -n1

现在,将其捕获到一个变量中:

Now, to catch it into a variable:

BUILD=$(cat file.txt | sort -V | tail -n1)

这篇关于用于对 debian 版本号进行排序的 Shell 脚本 (line_5.4.3-2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆