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
LVM: Reduce an existing Volume Group by removing one of its disks
Viewed 2633 times since Sat, Jun 2, 2018
RHCS6: Quorum disk and heuristics
Viewed 4519 times since Sun, Jun 3, 2018
A tcpdump Tutorial and Primer with Examples
Viewed 5463 times since Sun, Jun 17, 2018
18 Quick ‘lsof’ command examples for Linux Geeks
Viewed 11813 times since Sun, Jun 30, 2019
ZFS: Verify/change properties of a zfs filesystem
Viewed 2727 times since Sun, Jun 3, 2018
Top 10 darmowych i publicznych serwerów DNS
Viewed 2488 times since Tue, May 22, 2018
Oracle Linux 7 – How to audit changes to a trusted file such as /etc/passwd or /etc/shadow
Viewed 3101 times since Wed, Jul 25, 2018
Fedora 32: Simple Local File-Sharing with Samba CIFS Linux
Viewed 8972 times since Sun, Dec 6, 2020
RHEL: Enabling standard ftp/telnet
Viewed 3625 times since Sun, May 27, 2018
Linux Proxy Server Settings – Set Proxy For Command Line
Viewed 3801 times since Mon, Feb 18, 2019