Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Sep 2017 20:34:28 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Ernie Luzar <luzar722@gmail.com>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: Is it possible to sort a key field right to left
Message-ID:  <20170914203428.6aef9627.freebsd@edvax.de>
In-Reply-To: <59BA9B3C.5010106@gmail.com>
References:  <59BA9B3C.5010106@gmail.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Thu, 14 Sep 2017 11:07:40 -0400, Ernie Luzar wrote:
> I have a file containing a list of host domain names known to contain 
> viruses.
> 
> I want to sort the host names from right to left so they are grouped 
> together by like host name suffixes.
> 
> Is this possible?

Yes, easily, and provided by the OS. The "sort" command can do it.

Example:

	... | sort -t '.' +2 | ...

Use the -t parameter to define the field separator, and +N to
set the sorting field (+2 means to sort according to the 3rd
field, i. e., +N means "go to the right N fields").

See "man sort" for details.


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20170914203428.6aef9627.freebsd>