How to sort IP addresses in Linux
Article Number: 42 | Rating: 4/5 from 1 votes | Last Updated: Thu, May 24, 2018 8:15 PM
How to sort IP addresses in Linux
Answer:
When you have a file ip.txt contains a list of IP addresses, e.g.
127.0.0.2
127.0.0.1
10.10.10.1
To sort it, you can use the following command
# sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ip.txt
10.10.10.1
127.0.0.1
127.0.0.2
source: http://www.linuxask.com/questions/how-to-sort-ip-addresses-in-linux