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: Reinstalling Boot Loader on the Master Boot Record (MBR)
Viewed 3107 times since Sun, May 27, 2018
RHCS6: Luci - the cluster management console
Viewed 3009 times since Sun, Jun 3, 2018
10 nmap Commands Every Sysadmin Should Know
Viewed 9712 times since Wed, May 22, 2019
Testing TLS/SSL encryption
Viewed 13008 times since Thu, Jan 16, 2020
Linux 20 Netstat Commands for Linux Network Management
Viewed 9374 times since Mon, Sep 21, 2020
List of 10 Must Know Oracle Database Parameters for Database Administrator
Viewed 117092 times since Thu, Jun 21, 2018
Używanie rsync poprzez Secure Shell
Viewed 40892 times since Thu, May 24, 2018
How to mount software RAID1 member using mdadm
Viewed 2881 times since Wed, Oct 3, 2018
Using IOzone for Linux disk performance analysis
Viewed 7379 times since Wed, Jul 25, 2018
Configuring VLAN interfaces in Linux
Viewed 5172 times since Mon, May 21, 2018