Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

macos - How to simulate "sort -V" on Mac OSX

I have written a bash script that I need to work identically on linux and mac osx that relies on the sort command. I am piping the output of git tag -l to sort to get a list of all the version tags in the correct semantic order. GNU offers -V which makes this automagic but mac osx does not support this argument so i need to figure out how to accomplish this sort order without it.

6.3.1.1
6.3.1.10
6.3.1.11
6.3.1.2
6.3.1.3
...

needs to be sorted as

6.3.1.1
6.3.1.2
6.3.1.3
...
6.3.1.10
6.3.1.11
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can download coreUtils from http://rudix.org/packages/index.html . It contains "gnusort" with support "sort -V" sintax


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...