Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

up vote 6 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.