-2

I have a simple data set. example:

IP address,number of times it appears

192.168.0.10,11
192.168.0.1,15
192.168.0.120,9

I want to use the sort command to sort these by the largest number of times the IP has been seen. the output should look like:

192.168.0.1,15
192.168.0.10,11
192.168.0.120,9
tripleee
  • 175,061
  • 34
  • 275
  • 318

1 Answers1

1

Use -k to specify the column. Don't forget about -n to use numeric ordering.

sort -n -k2 file.txt
Tim Zimmermann
  • 6,132
  • 3
  • 30
  • 36