[Nottingham] shell script guru rqd.

Martin Garton nottingham at mailman.lug.org.uk
Tue Jan 14 13:24:00 2003


On 14 Jan 2003, Ben P. Blackburne wrote:

> On Tue, 2003-01-14 at 12:05, BUNTER MATTHEW wrote:
> 
> > 
> > So what I want is to inverse the list of publications. Last first, first
> > last etc.
> 
> If this is all you want to do, use tac (reverse cat).

Just what i was going to say!

Alternatively, to re-sort the list, use something like this: 
(assuming that all the lines contain a 4-digit year)


gawk --re-interval <list.txt '{l = match($0 , "[[:digit:]]{4}" ) ; if 
(l>0) print substr($0, RSTART, RLENGTH) $0}' | sort -r | sed 's/^....//'

(except without the linebreaks)


-- 
Martin.