Showing posts with label natural sort. Show all posts
Showing posts with label natural sort. Show all posts

Friday, February 25, 2011

sort list of ip addresses

Simple bash command to sort a list of IP Addresses, sorted ascending, by each octet.
# sorts file "sloppy_ip_list" into new file "sorted_ip_list"
sort -u -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 < sloppy_ip_list > sorted_ip_list


List all ip addresses on linux box, sorting in ascending order.
ifconfig | grep inet | cut -d ':' -f 2 | cut -d ' ' -f 1 | sort -u -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4