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
Linux Proxy Server Settings – Set Proxy For Command Line
Viewed 3183 times since Mon, Feb 18, 2019
Fake A Hollywood Hacker Screen in Linux Terminal linux FUN
Viewed 5605 times since Thu, Apr 18, 2019
How to enable automatic security updates on CentOS 7 with yum-cron
Viewed 2367 times since Fri, Oct 26, 2018
Linux Health Check Commands
Viewed 2934 times since Fri, Jun 8, 2018
Index » Community Contributions » System encryption using LUKS and GPG encrypted keys for arch linux
Viewed 2949 times since Fri, Jul 13, 2018
RHEL: Change system’s hostname
Viewed 3324 times since Sun, May 27, 2018
RHEL: iSCSI target/initiator configuration on RHEL6
Viewed 8609 times since Sat, Jun 2, 2018
INSTALACJA MIB SNMP W SYSTEMIE CENTOS/RHEL 6
Viewed 12823 times since Fri, Nov 30, 2018
Learn Linux System Auditing with Auditd Tool on CentOS/RHEL
Viewed 4107 times since Fri, Apr 5, 2019
RHEL: Route network packets to go out via the same interface they came in
Viewed 2881 times since Sat, Jun 2, 2018