Sorting numerically with sort
I have a logfile with entries on the following form that I want to sort numerically on the ID number field.
2011-10-06 08:13:48 ID_39 message1
2011-10-06 09:13:5s ID_239 message2
I have tried to accomplish this with the sort command but I don't seem to get the keys right. Sorting with sort -b -k 3 just sort things alphabetically and -n (numeric sort) does not seem to help.
How do I go from this
ID_394
ID_65
ID_9
ID_99
To this?
ID_9
ID_65
ID_开发者_Go百科99
ID_394
sort -t _ -k 2 -n, which means: separate fields by _, sort numerically by second field.
Found out that also sort -b -k 3.4 -n did the trick. With -b for ignoring leading blanks, -k 3.4 to sort for the third field, from the fourth letter and -n for numerically.
加载中,请稍侯......
精彩评论