Home > Net >  Linux sort by column and in reverse order
Linux sort by column and in reverse order

Time:06-20

I'm trying to sort a file by second column, but in reverse order. I tried:

sort -k2n -r file.txt

The output is not in reverse order, so it seems -r is being ignored. I'm in CentOS.

CodePudding user response:

Try to add a space after the -k and before the column position. e.g. something like below

sort -k 2n -r file.txt

CodePudding user response:

I just needed to remove the "n" next to column number:

sort -k 2 -r file.txt
  • Related