How to sort IP addresses in Linux

How to sort IP addresses in Linux


When you have a file ip.txt contains a list of IP addresses, e.g.

To sort it, you can use the following command

# sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ip.txt

There are no attachments for this article.
Related Articles RSS Feed
Deskshare TLS over Stunnel
Viewed 2562 times since Fri, Sep 28, 2018
Using stunnel and TinyProxy to obfuscate HTTP traffic
Viewed 6353 times since Fri, Sep 28, 2018
RHEL: Displaying system info (firmware, serial numbers... )
Viewed 11566 times since Sun, May 27, 2018
Tcpdump Examples Linux
Viewed 5627 times since Fri, Nov 16, 2018
LVM: Mount LVM Partition(s) in Rescue Mode
Viewed 4471 times since Sat, Jun 2, 2018
HowTo: Find Out Hard Disk Specs / Details on Linux
Viewed 3050 times since Mon, Jan 28, 2019
debian How to Upgrade Debian 8 Jessie to Debian 9 Stretch
Viewed 2123 times since Sun, Sep 23, 2018
ZFS: Verify/change properties of a zfs filesystem
Viewed 2325 times since Sun, Jun 3, 2018
How to Clear RAM Memory Cache, Buffer and Swap Space on Linux
Viewed 2102 times since Mon, Nov 23, 2020
How To Find Largest Top 10 Files and Directories On Linux / UNIX / BSD find
Viewed 3542 times since Mon, Oct 29, 2018