shell脚本的Debian版本号排序(line_5.4.3-2) [英] Shell script to sort debian version numbers (line_5.4.3-2)

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

问题描述

我有一个文本文件中的条目重新presenting构建版标签和相同的格式版本号为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脚本我需要排序版本构建'上面的列表中,并获得最后一行,这在上面的例子是 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)

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

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