Answers for "sort directory by version numbers"

0

sort directory by version numbers

# Assuming you have a list of versions like v1.6.23 in a test.txt file
# You can sort it by the following command
sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n test.txt

## From a file with versions 
## v1.0.15
## v1.0.9
## v1.0.3
## v1.0.1
## v1.0.5
## v1.0.10
## v1.0.4
## v1.0.6
## v1.0.2

## You get the following
## v1.0.15
## v1.0.10
## v1.0.9
## v1.0.6
## v1.0.5
## v1.0.4
## v1.0.3
## v1.0.2
## v1.0.1
Posted by: Guest on September-29-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language