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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reorder a Text File

Status
Not open for further replies.

jtanner

Technical User
Feb 18, 2007
39
US
Hello,

I have a Bourne shell script that uses a small text file (example below). How can I re-order each of the lines in reverse order and write out to another file?

Original File Contents
Code:
A xxxx xxx xxx
B xxx xxx
C xxxxxx x  
D xxxxxxxx

Desired File Contents
Code:
D xxxxxxxx
C xxxxxx x 
B xxx xxx
A xxxx xxx xxx

Thanks,

JT
 
man sort (the -r option)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

On Linux you could use tac

NAME
tac - concatenate and print files in reverse

DESCRIPTION
Write each FILE to standard output, last line first.

from "man tac"



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top