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!

sort on multiple keys

Status
Not open for further replies.

teqmem

Programmer
Nov 26, 2004
114
0
0
US
Hello,

Say I have a file with plain text as shown below. Some columns may have multiple words (like "DESC 1", "DESC 1 2", "DESC 1 2 3"). Let's say the file below has 4 columns: 1st(AA), 2nd(BB), 3rd(DESC 1, ...), 4th(CC 1, ...).

Code:
1234567890123456789012345678901234567890
AA  BB   DESC 1 2 3          CC 1 2 3
AA  BB   DESC 1 2            CC 1 2
AA  BB   DESC 1              CC 1

I'd like to use the UNIX sort utility to sort based on these orders: 4th, 3rd, 2nd, then 1st.

How would I construct the key parameters (-k) to the sort utility?

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top