From owner-freebsd-questions Thu Jan 4 23:09:00 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id XAA12791 for questions-outgoing; Thu, 4 Jan 1996 23:09:00 -0800 (PST) Received: from MediaCity.com (root@easy1.mediacity.com [205.216.172.10]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id XAA12785 for ; Thu, 4 Jan 1996 23:08:57 -0800 (PST) Received: (from brian@localhost) by MediaCity.com (8.6.11/8.6.9) id XAA05741; Thu, 4 Jan 1996 23:08:28 -0800 From: Brian Litzinger Message-Id: <199601050708.XAA05741@MediaCity.com> Subject: Re: sorting by character position To: fqueries@parody.tecc.co.uk (James Raynard) Date: Thu, 4 Jan 1996 23:08:28 -0800 (PST) Cc: brian@MediaCity.com, freebsd-questions@freebsd.org In-Reply-To: from "James Raynard" at Jan 4, 96 11:21:41 pm X-Mailer: ELM [version 2.4 PL24 ME8b] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org Precedence: bulk > > On Mon, 1 Jan 1996, Brian Litzinger wrote: > > All I want to do is > > > > sort -n -d -k 14,29 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 http[s]://www.mpress.com speakfree.mpress.com [use -t (GSM)]