sort contents of a file based upon the fields

Friday, December 28, 2012 0 Comments


sort contents of a file based upon the fields

1.2.100.4
1.2.3.4
10.1.2.3
9.1.2.3

I wish to sort them so that they are sorted by version. i.e:

1.2.3.4
1.2.100.4
9.1.2.3
10.1.2.3

Solution 1
----------
sort -V versions.txt

solution 2
----------
sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n test.txt

0 comments: