Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I have a tab-separated file, and I want to sort it by its columns 9, 14, and 16. By this I mean that all rows that agree at column 9 should be sorted by column 14, and among these, those that also agree on column 14 should be sorted by column 16. (All columns should be sorted ascendingly, but the first two should be sorted alphabetically, and the remaining one numerically.)

I've tried various forms of (gnu) sort, but I don't get the desired sort order. The man page has not helped. Can anyone tell me the right incantation for achieving the sort described above?

share|improve this question

marked as duplicate by slm, rush, Anthon, jasonwryan, Gilles Jun 10 '13 at 22:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

up vote 3 down vote accepted
sort -t '\t' -k9,9 -k14,14 -k16,16n

(remember you need to specify where sort keys start and where they end, otherwise (as in when you use -k9 instead of -k9,9) they end at the end of the line).

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.