Date: Thu, 4 Jan 1996 23:08:28 -0800 (PST) From: Brian Litzinger <brian@MediaCity.com> To: fqueries@parody.tecc.co.uk (James Raynard) Cc: brian@MediaCity.com, freebsd-questions@freebsd.org Subject: Re: sorting by character position Message-ID: <199601050708.XAA05741@MediaCity.com> In-Reply-To: <Pine.BSF.3.91.960104231934.954A-100000@parody.tecc.co.uk> from "James Raynard" at Jan 4, 96 11:21:41 pm
next in thread | previous in thread | raw e-mail | index | archive | help
>
> On Mon, 1 Jan 1996, Brian Litzinger wrote:
> > All I want to do is
> >
> > sort -n -d -k 14,29 <unsorted >sorted
> >
> > where -k 14,29 is supposed to mean that sort is supposed to consider
> > the data in columns 14 - 29 of each line as the key to sort by.
> >
> > However, from my reading of the sort man page, it doesn't seem to
> > have this functionality. However, I remember I used to be able
> > to do this in my SYSV days.
>
> It seems to be there in 2.1.0R:-
>
> -k POS1[,POS2]
> An alternate syntax for specifying sorting keys.
> The fields and character positions are numbered
> starting with 1.
> James
Unfortunately, further down in the man page is a definition for POS
which makes great sense, but I am unable to devine how to get
a purely character position oriented specification out of it.
I tried several test files and just couldn't quite get what I wanted
which was:
forbar flem ickto $1234588 gort sneakers flem
^^^^^^^^^^^
and I'd liked to sort on the columns indicated.
Except from man sort:
A position has the form f.c, where f is the number of the
field to use and c is the number of the first character
from the beginning of the field (for +pos) or from the end
of the previous field (for -pos). The .c part of a posi-
tion may be omitted in which case it is taken to be the
first character in the field. If the -b option has been
given, the .c part of a field specification is counted
from the first nonblank character of the field (for +pos)
or from the first nonblank character following the previ-
ous field (for -pos).
A +pos or -pos argument may also have any of the option
letters Mbdfinr appended to it, in which case the global
ordering options are not used for that particular field.
The -b option may be independently attached to either or
both of the +pos and -pos parts of a field specification,
and if it is inherited from the global options it will be
attached to both. If a -n or -M option is used, thus
implying a -b option, the -b option is taken to apply to
both the +pos and the -pos parts of a key specification.
Keys may span multiple fields.
--
Brian Litzinger Powered by FreeBSD
<brian@mediacity.com> http[s]://www.mpress.com
speakfree.mpress.com [use -t (GSM)]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601050708.XAA05741>
