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
Fałszujemy rozpoznania skanerów #1
Viewed 3094 times since Mon, May 21, 2018
Installing and Configuring stunnel on CentOS 6
Viewed 4177 times since Fri, Sep 28, 2018
linux-training.be gives you books for free to study Linux
Viewed 5017 times since Sat, Jun 2, 2018
SYS: Configure a local repository. local repo
Viewed 11058 times since Mon, Oct 29, 2018
Using stunnel and TinyProxy to obfuscate HTTP traffic
Viewed 7063 times since Fri, Sep 28, 2018
List DNS records, nameservers of a domain from command line
Viewed 2076 times since Sun, Sep 30, 2018
10 Linux rsync Examples to Exclude Files/Directories
Viewed 11015 times since Wed, Oct 31, 2018
List of 10 Must Know Oracle Database Parameters for Database Administrator
Viewed 130001 times since Thu, Jun 21, 2018
Linux RedHat How To Create An RPM Package
Viewed 3334 times since Sun, Jan 9, 2022
Linux - How to get Memory information
Viewed 1997 times since Fri, Jun 8, 2018