Sorting problem "sort -k 16,29 sample.txt > output.txt"

Hi all,

Iam trying to sort the contents of the file based on the position of the file.
Example:

$cat sample.txt
0101020060731 ## Header record
1c1 Berger Awc ANP20070201301 4000.50
1c2 Bose W G ANP20070201609 6000.70
1c2 Andy CK ANP20070201230 28000.00
1c3 Bharg ANP20070201847 9000.80
1c3 Peter Neid ANP20070201109 2000.50
1c3 Ralf Tiger ANP20070201365 4000.10
900006 ## Trailer record

Where ANP*********** is the policy number and starts in the file from 16th position. I need to sort based on these policy numbers.
Iam using the "Sort" Option as below:

sort -k 16,29 sample.txt > output.txt

But it is not sorting based on Policy numbers.
Could any one help me to fix it.

Many Thanks and Regards,
Ganapati :o

Turn off field separation by using a field sep character that does not occur in any record. Try the : character, then everything is in field1

sort -t: -k 1.16,1.29 sample.txt > output.txt

This sorts character positions 16-29.

Thanks very much,

I tried this code

sort -k 2,2 file.txt

the -k option requires m.n
m= field number
n = character position

You are missiing character positions.

Use -k2.1,2.10 or something.