I'm trying to sort this file by field 1 (ignoring the ccc) and when equal, by field 2 as a number:
ccc1 4
cccY 1
cccY 5
cccX 2
cccX 10
ccc10 4
ccc1 10
ccc2 5
I'm running sort as sort -t $'\t' -k 1.4,1n -k 2,2n" but, I'm not getting the expected output:
cccY 1
cccX 2
cccY 5
cccX 10
ccc1 4
ccc1 10
ccc2 5
ccc10 4
Why is the cccY and cccX mixed? It should give first both cccX and then both cccY, right?
thanks,
FGV
PS - In case you want to reproduce it, just run:
echo -e "ccc1\t4\ncccY\t1\ncccY\t5\ncccX\t2\ncccX\t10\nccc10\t4\nccc1\t10\nccc2\t5" | sort -t $'\t' -k 1.4,1n -k 2,2n
-k 1.4>>,1<<n? Isn't the comma a 'range' operator, where you'd expect the 2nd part of the range to be value greater than the first? Good luck!