I'm trying to sort a file where typically (not always) the lines are
whatever:[A-Ba-b0-9_]: values
where fields are separated with :
. Some lines do not follow this pattern, I'm not interested in them, they can be anywhere in the output.
I want to sort the lines only on the second column (and not on values), but when I do sort -t: -k 2 myfile
, it sorts the file on all the line.
How to use the -k
in order to have what I need?
sort
has different options on Solaris and Linux. Also, is the field numeric or alphanumeric? – unxnut May 28 '13 at 15:05grep -v : myfile | sort -t: -k 2
to see if that gives you the desired result? – unxnut May 28 '13 at 15:12:
– Jav May 28 '13 at 15:19