Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!rutgers!att!pegasus!hansen From: hansen@pegasus.ATT.COM (Tony L. Hansen) Newsgroups: comp.unix.questions Subject: Re: sorting and reversing lines of a file Summary: use the "tac" (reverse cat) program Keywords: reverse file Message-ID: <2585@pegasus.ATT.COM> Date: 11 Feb 89 02:12:50 GMT References: <9056@burdvax.PRC.Unisys.COM> <9510@smoke.BRL.MIL> <899@auspex.UUCP> Reply-To: hansen@pegasus.ATT.COM (Tony L. Hansen) Organization: AT&T Bell Laboratories, Lincroft, NJ, USA Lines: 45 >>(1) reverse the order of lines in a file >> but leave the lines themselves intact. >> The Unix utility does just the opposite of this. This sounds like a job for "tac" which has been posted at least a couple of times to the net. Here's the man page. NAME tac - concatenate and print files in reverse SYNOPSIS tac file ... DESCRIPTION Tac reads each file in sequence and writes it on the standard output with the lines in reverse order. Thus: tac file prints the file in reverse, and: tac file1 file2 >file3 concatenates the first two files, reversed, and places the result on the third. tac file | tac will reproduce the contents of the file. If no input file is given, or if the argument - is encountered, tac reads from the standard input. WARNING Command formats such as tac file1 file2 >file1 will cause the original data in file1 to be lost, therefore, take care when using shell special characters. SEE ALSO cat(1). Tony Hansen att!pegasus!hansen, attmail!tony