I am trying to sort a file:
TX001;A0004|Number|5|0|Y|1
TX001;A0110|VARCHAR|5|0|Y|4
TX001;A1332|VARCHAR|15|0|Y|3
TX001;B3321|VARCHAR|15|0|Y|5
TX001;C1321|VARCHAR|15|0|Y|2
TY001;A1234|Number|5|0|Y|3
TY001;C2335|VARCHAR|5|0|Y|1
TY001;B2133|VARCHAR|15|0|Y|2
TZ001;A1234|Number|5|0|Y|3
TZ001;A2133|VARCHAR|5|0|Y|1
TZ001;C0133|VARCHAR|15|0|Y|2
The expected output result is:
TX001;A0004|Number|5|0|Y|1
TX001;C1321|VARCHAR|15|0|Y|2
TX001;A1332|VARCHAR|15|0|Y|3
TX001;A0110|VARCHAR|5|0|Y|4
TX001;B3321|VARCHAR|15|0|Y|5
TY001;C2335|VARCHAR|5|0|Y|1
TY001;B2133|VARCHAR|15|0|Y|2
TY001;A1234|Number|5|0|Y|3
TZ001;A2133|VARCHAR|5|0|Y|1
TZ001;C0133|VARCHAR|15|0|Y|2
TZ001;A1234|Number|5|0|Y|3
I need to sort based on the last numeric column. When I try the sort using -n
, the order of the first column is changing.
Tried using sort -t "|" -k 6,6n FNAM.txt
but it results numerical sort chaning the first column order.
I need to sort based on the last column numerically, keeping the first column of table name unaffected.