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
How to schedule crontab in Unix Operating Systems
Viewed 2978 times since Fri, Jun 8, 2018
Linux - How to perform I/O performance test with dd command
Viewed 7110 times since Fri, Jun 8, 2018
LVM: Reduce an existing Volume Group by removing one of its disks
Viewed 3254 times since Sat, Jun 2, 2018
How to do a Filesystem Resize (ext3/ext4) on Redhat running on VMware
Viewed 11936 times since Wed, Jul 25, 2018
Linux Proxy Server Settings – Set Proxy For Command Line
Viewed 6666 times since Mon, Feb 18, 2019
LVM: Extend an existing Logical Volume / Filesystem
Viewed 3538 times since Sat, Jun 2, 2018
Set Up SSH Tunneling on a Linux / Unix / BSD Server To Bypass NAT
Viewed 12297 times since Fri, May 15, 2020
UUIDs and Linux: Everything you ever need to know [Update]
Viewed 5933 times since Tue, Jul 17, 2018
RHEL: Rebuilding the initial ramdisk image
Viewed 9406 times since Sat, Jun 2, 2018
ZFS: Verify/change properties of a zfs filesystem
Viewed 3642 times since Sun, Jun 3, 2018