How to sort IP addresses in Linux

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
Attachments
There are no attachments for this article.
Related Articles RSS Feed
RHEL : How to deal with “CLOSE_WAIT” and “TIME_WAIT” connection
Viewed 26774 times since Thu, Feb 14, 2019
RHEL: Rename a network interface on RHEL 7
Viewed 10894 times since Sat, Jun 2, 2018
Inxi – A Powerful Feature-Rich Commandline System Information Tool for Linux
Viewed 19143 times since Sat, Jun 2, 2018
Linux RedHat How To Create An RPM Package
Viewed 3478 times since Sun, Jan 9, 2022
RHEL: udev rules basics
Viewed 9286 times since Sat, Jun 2, 2018
Linux get the list of FC HBA’s and WWPN
Viewed 3719 times since Tue, May 22, 2018
How To: Linux Hard Disk Encryption With LUKS [ cryptsetup Command ]
Viewed 7549 times since Fri, Jul 13, 2018
OpenSSL: Check SSL Certificate Expiration Date and More
Viewed 7111 times since Mon, Feb 18, 2019
rabbitmq Troubleshooting TLS-enabled Connections
Viewed 2718 times since Sun, Dec 6, 2020
KONTO SFTP Z CHROOTEM Z UŻYCIEM OPENSSH-SERVER NA CENTOS/RHEL6
Viewed 2038 times since Fri, Nov 30, 2018