bash - Sorting in unix while other field doesn't change -


i have file

1 4 2 1 2 1 1 2 4 5 1 2 4 5 9 2 3 4 5 1 1 0 2 1 5 2 2 2 1 1 

sort -k1 file gives

1 0 2 1 5 1 1 2 4 5 1 2 4 5 9 1 4 2 1 2 2 2 2 1 1 2 3 4 5 1 

i want first field sorted, others remains should at, e.g. sorted file should give:

1 4 2 1 2 1 1 2 4 5 1 2 4 5 9 1 0 2 1 5 2 3 4 5 1 2 2 2 1 1 

similarly sort -k1r testsort gives

2 3 4 5 1 2 2 2 1 1 1 4 2 1 2 1 2 4 5 9 1 1 2 4 5 1 0 2 1 5 

when want

2 3 4 5 1 2 2 2 1 1 1 4 2 1 2 1 1 2 4 5 1 2 4 5 9 1 0 2 1 5 

how can in unix?

try this:

sort -s -n -k 1,1 

this work, , learn more can see here


Comments

Popular posts from this blog

python - matpltolib navigation toolbar edit curves and parameters line color automatically changes issue -

node.js - Nodejs javascript implementation of PBEWithMD5AndTripleDES/CBC/PKCS5Padding -