|
From: | Ed Morton |
Subject: | Re: [help-recutils] Looking For Recsort |
Date: | Mon, 31 Oct 2011 12:48:54 -0500 |
Jose - "recsel -S" sounds like just what I'm looking for. I'd be interested in knowing what sorting options it supports, for example:
1) Can you sort on field X and then field Y or just on one field at a time?
2) Can you specify the sort should be alphabetic vs numerical or is it only alphabetical?
so if you have a pointer to the documentation on that I'd like to take a look.
Thanks,
Ed.
Hi.
recutils 1.3 does not support any sorting facility. But recutils 1.4
In the online documentation I don't see a recutils tool to sort
entries in the database. Is there one? Or are there options for
"recsel" or some other way to output the records in a specific
order?
(which will be released this Wednesday) does. The pre-release 1.3.90 at
http://alpha.gnu.org/gnu/recutils includes that support.
So you can wait until 1.4 is out, get the development version from git
or install the 1.3.90 pre-release.
In a nutshell, with recutils >= 1.3.90 you can use the %sort special
field to determine the desired sorting criteria for a record set. For
example, having the following database:
%rec: Item
%key: Id
%sort: CheckInDate
Id: 10
CheckInDate: 20 November 2011
Id: 20
CheckInDate: 15 November 2011
Operations with recsel, recfmt or any other recutils extracting
information from the recfile will honour %sort and display the entries
in the order given by CheckInDate:
$ recsel -t Item
Id: 20
CheckInDate: 15 November 2011
Id: 10
CheckInDate: 20 November 2011
Alternatively, you can use the new -S|--sort command line argument in
recsel and in recfmt to specify another field to be used as the sorting
criteria. If you use this option then %sort will be ignored. For
example:
$ recsel -t Item -S Id
Id: 10
CheckInDate: 20 November 2011
Id: 20
CheckInDate: 15 Novemer 2011
recfix now supports a new --sort operation that will physically sort all
the record sets in a given file:
$ recfix --sort database.rec
Hope this helps.
--
Jose E. Marchesi address@hidden
GNU Project http://www.gnu.org
[Prev in Thread] | Current Thread | [Next in Thread] |