Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!wuarchive!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!topgun.dspo.gov!lanl!cmcl2!adm!xadmx!bush%ecs.oxford.ac.uk@nsfnet-relay.ac.uk From: bush%ecs.oxford.ac.uk@nsfnet-relay.ac.uk (Mark Bush) Newsgroups: comp.unix.questions Subject: Re: Reversing a file? Message-ID: <21080@adm.BRL.MIL> Date: 6 Oct 89 17:41:48 GMT Sender: news@adm.BRL.MIL Lines: 18 > Does somebody have an elegant shell script for reversing the lines of a > file? I've come up with the following short one: For all perl fans: while (<>) { $line{$.} = $_; } for ($i = $.; $i > 0; $i--) { print $line{$i}; } Mark Bush bush%uk.ac.oxford.prg@ac.uk Teaching Support Programmer bush%prg.oxford.ac.uk@nsfnet-relay.ac.uk OUCL ...!uunet!mcvax!ukc!ox-prg!bush