Reversing a file?

David C. Raines davr at hrtix.UUCP
Thu Oct 5 00:18:35 AEST 1989


In article <MONTNARO.89Oct2224215 at sprite.crd.ge.com>, montnaro at sprite.crd.ge.com (Skip Montanaro) writes:
> Does somebody have an elegant shell script for reversing the lines of a
> file? I've come up with the following short one:

Awk version:

{
	array[NR] = $0
}
END {
	for (i = NR; i > 0; i--)
		print array[i]
}
-- 
David Raines			TCA  5 National Dr., Windsor Locks, CT 06096
UUCP:  ...!uunet!hrtix!davr		



More information about the Comp.unix.questions mailing list