Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a File Backwards

Status
Not open for further replies.

midge25

Programmer
Jul 19, 2002
9
Hi,

I wish to read a file backwards.

e.g.

File contains

Apple
Banana
Carrot
Daisy
Elephant
.....

This should read as follows:

Elephant
Daisy
Carrot
Banana
Apple

I am sure this possible but just cannot remember how.

Thanks in advance,

Midge25
 
awk '{a[++n]=$0}END{for(i=n;i>0;--i)print a}' /path/to/input

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

Works wonders.. Thank you very much.

midge25
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top