Reputation: 347
I have a file in which there are numbers like
6.3.0.00.220
6.3.0.00.220C
6.3.0.00.220EH
6.3.0.00.221
6.3.0.00.221C
6.3.0.00.221EH
and so on
I want them to be groped/sorted as
6.3.0.00.220EH
6.3.0.00.221EH
6.3.0.00.220C
6.3.0.00.221C
6.3.0.00.220
6.3.0.00.221
Basically EH ones together in ascending then C together in ascending and then the rest in ascending.
I am trying sort -k 1.10,1.14 -nr | sort -k 1.13 -r
but not getting the exact output.
Upvotes: 2
Views: 375
Reputation:
Test file:
$ cat test.txt
6.3.0.00.220
6.3.0.00.220C
6.3.0.00.220EH
6.3.0.00.221
6.3.0.00.221C
6.3.0.00.221EH
Running a command:
$ cat <(grep -E -e "EH$" test.txt | sort) \
<(grep -E -e "C$" test.txt | sort) \
<(grep -E -v "(EH)|(C)$" test.txt | sort)
6.3.0.00.220EH
6.3.0.00.221EH
6.3.0.00.220C
6.3.0.00.221C
6.3.0.00.220
6.3.0.00.221
Upvotes: 1