This question already has an answer here:
Here is my file, the first line is not part of it (the one with
Fname Lname Age Children John Doe 61 2 Mary Jane 32 5 Delta Cross 30 5 Sui Ace 24 1
I want to sort this file based on number of children. It should be sorted from most children to least children.
Here is my command:
sort -k 4 -n -r file.txt, which says sort based on the 4th column, numeric sort, and reverse. This yields:
Mary Jane 32 5 Delta Cross 30 5 John Doe 61 2 Sui Ace 24 1
The way my text does it is
sort -k4nr file.txt. I have two questions regarding this:
Firstly, I thought our options must be separated by spaces (not joined together)? Is this not the case for sort, or not the case for any of the commands?
Secondly, when doing it this way, I get the "right" order, but
Delta is first:
Delta Cross 30 5 Mary Jane 32 5 John Doe 61 2 Sui Ace 24 1
Why is this?