On Thu, 2 Dec 2010, gregwm wrote:

> how do you tell sort to ignore the first x characters of each line and 
> start the key at character x+1?


I don't think it can do that.  It want's a delimiter and keys.  If you can 
think of a character that doesn't occur in the file, you might insert it 
after x characters, use it as a delimiter, sort by the second field and 
then remove the character from the output.  Well, that's what I'd do.  I 
can tell you how if you can tell me a character to use.  I'd use tab if 
the file contains no tabs.  Something like this (for x = 9) will often 
work:

perl -pe 's/^(.{9})/$1\t/' infile | sort -t'\t' -k2,2 | perl -pe 's/^(.{9})\t/$1/'

Wait, here's a better idea: Move the first x characters from the beginning 
of the line to the end, sort, then move them back to the beginning:

perl -pe 's/^(.{9})(.*)$/$2\t$1/' infile | sort | perl -pe 's/^(.*)\t(.{9})$/$2$1/'

You don't really need that tab in there but it somehow makes me feel 
better.  These methods require that every line has at least x characters 
(x=9 in my example code).

Mike