#!/bin/sh

#
# ipsort
#
# A filter to sort a file like /etc/hosts by IP address.
#

ip='[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*'

sed "s/^\($ip\)/\1./" | sort -n -t. +0 -1 +1 -2 +2 -3 +3 -4 | sed "s/^\($ip\)./\1/"


© 1998, Boyd Roberts: boyd@fr.inter.net