groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Groff] Re: query w.r.t. references follow-up


From: Ted Harding
Subject: RE: [Groff] Re: query w.r.t. references follow-up
Date: Tue, 18 Jan 2000 18:45:11 -0000 (GMT)

On 18-Jan-00 Dean Allen Provins wrote:
> 
> What I really want is a sorted list of my text database(s).  Sort key
> should be by authors, and/or date of publication.
> 
> Does anyone have some code to do this?

Hi Dean,

groff itself does not have a utility for this. Other UNIX installations
of troff may have a program called sortbib which does just that, for
refer databases.

You might try 'lookbib' on a database which has been indexed with
'indxbib' and seeing if you can get this to work for you; but
I don't hold out much hope.

There may be some other UNIX utilities available on some installation
for processing files with this kind of structure (it is generic,
not just a 'refer' format).

If you want a sorted formatted printout, then of course refer can
do this on its own. However, I infer that you want to re-structure
the database files themselves so that they are in sorted order
internally.

If push comes to shove, as they say, you could do it with a couple
of awk scripts.

The _strategy_ (the _details_ are finicky) is as follows.

The first awk script treats the database as a series of multiline
records separated by blank lines; each line has an identifying tag.
It uses a specially defined function to extract lines (now "fields")
with given tags, and compose a sort key out of these. It then prints
out a file, each line of which is made up of the one-line concatenation
of the original lines in the database record following after the
constructed sort key.

This file is then piped to the UNIX sort command, which produces
a file with the lines in sorted order.

Then the second awk script is applied to this file, which unpacks
the original database lines from the lines in this file, discarding
the sort key. The result is a reconstruction of the original
database, but with the records in a suitably sorted order.

A tersely described example of how to do this can be found in the book
"The AWK programming language" by Aho, Kernighan and Weinberger
(Addison-Wesley 1988), in Section 3.4 (Multiline Records)
sub-section "Name-Value Data", pp 86-88 in my copy).

(There is a more recent book, "GAWK: The GNU Awk User's Guide"
by Arnold D. Robbins, Free Software Foundation 1989ff), which also gives
an introduction to multiline records, but does not give sufficient
detail to define a complete solution to the problem. Nor does it
have the clarity of the other).

I hope this helps.
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 18-Jan-00                                       Time: 18:45:10
------------------------------ XFMail ------------------------------


reply via email to

[Prev in Thread] Current Thread [Next in Thread]