Specifying sort fields
Dan Nelson
dnelson at allantgroup.com
Thu Apr 22 14:34:58 PDT 2004
In the last episode (Apr 22), JJB said:
> How to specify the fields the sort program is to sort on?
>
> My file has blanks between the fields and I want to sort on
> field number 9 which is ip address.
>
> I want to sort filea and put results in fileb.
>
> A sample of the sort command to be used from the command line would
> go an long way to understanding how to use it.
Somthing like "sort -k 9bn < filea > fileb" should work, but it will
end up sorting only the first octect. If you can get your addresses to
be 0-padded (000.000.000.000), you can drop the 'n' from the sort
command and just do a plain ascii sort.
--
Dan Nelson
dnelson at allantgroup.com
More information about the freebsd-questions
mailing list