Jan 262010
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