shell - How to sort alphanumeric column in unix with alphabet first and then numeric -
suppose have text file:
08174 c6517298 08184 p0785411 08184 k0255564 01234 56789012 09098 a9877756   i sort second column alphabet first , numeric
the expected outcome should be:
09098 a9877756 08174 c6517298 08184 k0255564 08184 p0785411 01234 56789012   i tried sort -gk2,2 , sort -k2,2, both not give me correct result. please help.
replace -gk2,2 -k2g (you meant -k option, right?) , add -k2
sort -k2g -k2 file   the key definition syntax f[.c][opts][,f[.c][opts]], f field number (2, in particular); opts 1 or more single-letter ordering options [bdfgimhnrrv].
note, don't need ,2, means stop sorting @ second column, , second column last.
the key option priorities applied in order passed them in command, i.e. -k2g applied first, -k2. 
Comments
Post a Comment