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
Fake A Hollywood Hacker Screen in Linux Terminal linux FUN
Viewed 7927 times since Thu, Apr 18, 2019
LVM: Extend SWAP size by adding a new Logical Volume
Viewed 3964 times since Sat, Jun 2, 2018
RHCS6: Install a two-node basic cluster
Viewed 4347 times since Sun, Jun 3, 2018
Linux: Disks diagnostic using smartctl
Viewed 16197 times since Wed, Jul 25, 2018
RHCS6: Show/Add GFS2/GFS journals
Viewed 13493 times since Sun, Jun 3, 2018
LVM: Extend SWAP size by growing existing Logical Volume
Viewed 3322 times since Sat, Jun 2, 2018
Jak wygenerować silne hasła jednorazowe w Linuksie?
Viewed 3036 times since Thu, May 24, 2018
logrotate Understanding logrotate utility
Viewed 2851 times since Sun, Jan 12, 2020
logrotate Log Rotate Configuration
Viewed 4032 times since Sun, Jan 12, 2020
RHCS6: Extend an existing Logical Volume / GFS2 filesystem
Viewed 4135 times since Sun, Jun 3, 2018