I need to sort IP addresses in bash

I would like to sort a list of IP addresses in bash.

Related tags: Linux

Credit: Original Poster

Either use sort to read the file, or pipe the IPs to sort.
Last octet only:
sort -t. -n -k 4 file_name
Whole IP:
sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n test

Rating: 2

Propose a different solution...