Unix & Linux: How to sort by multiple columns?
Channel: Roel Van de Paar
Date: 2020-08-15

Unix & Linux: How to sort by multiple columns?


The Question: 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?

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free-music | Images: https://stocksnap.io/license & others | With thanks to user Stephane Chazelas (https://unix.stackexchange.com/users/22565), user kjo (https://unix.stackexchange.com/users/10618), and the Stack Exchange Network (http://unix.stackexchange.com/questions/78925). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.