Re: [Nolug] Sorting lists of domains

From: Mark A. Hershberger <mah_at_everybody.org>
Date: Wed, 18 Jun 2003 19:02:15 -0500
Message-ID: <87isr3lyt4.fsf@mah.mcdermott.com>

<mrobinso@fpkc.com> writes:

> I'm looking for a utility - Linux or otherwise - to take a list of domains or even email
> addresses and sort them from the TLD down. In other words, treating periods as field
> delimiters and sorting fields from right to left. So, for example:

The following will get you what you want. Only for 3 levels,
though. Set the number of levels you want and adjust the sed
statements accordingly.

rev | \
   sed 's,\([^\.]*\)\.\([^\.]*\)\.*\([^\.]*\)$,:\3 :\2 :\1,' | \
   rev | sort |
   sed '{
          s,\([^\.]*\): \([^\.]*\): \([^\.]*\):$,\3.\2.\1,
          s,^\.+,,
        }'

-- 
As long as you have mystery you have health; when you destroy mystery
you create morbidity.			     -- G.K. Chesterson
___________________
Nolug mailing list
nolug@nolug.org
Received on 06/18/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST