How to UNIX sort by one column only?
Problem
I know that the -k option for the Unix sort allow us to sort by a specific column and all of the following. For instance, given the input file: Using , I get an output sorted by the 1st column and then by the 2nd: However, I want to keep the 2nd column ordering, like this: Is this possible with the command?
Error Output
2 3 2 2 1 2 2 1 1 1
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How to UNIX sort by one column only?
Give this a try: The disables 'last-resort' sorting, which sorts on everything that wasn't part of a specified key. The doesn't actually mean "this field and all of the following" in the context of numeric sort, as you can see if you try to sort on the second column. You're merely seeing ties broken by going to the rest of the line. In general, however, you need to specify to sort only on field one.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix