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

Sort question

Status
Not open for further replies.

pjb

Programmer
May 1, 2001
148
US
I have a flat file that needs to be sorted first by positions 23 thru 30, and thn by 68 thru 74. The records do not have any common field delimiters that I can use.
 
You can try something like this:
Code:
voidDelim=`echo "\001\c"`
sort -t"$voidDelim" -k 1.23,1.30 -k 1.68,1.74 infile
or if your sort utility don't know the -k option:
Code:
sort -t"$voidDelim"  +0.22 -0.29 +0.67 -0.73 infile

Hope This Help
PH.
 
Thanks,

What does the -t option do for me? I get the same results with or without it.
 
-t x : Use x as the field separator character
To sort a file based on columns, use the -t option to specify a
field separator character which does not appear in the input.

Anyway:
Code:
man sort

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top