[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trying to get sort keys to work
From: |
Philip Rowlands |
Subject: |
Re: Trying to get sort keys to work |
Date: |
Fri, 26 Oct 2007 18:33:52 +0100 (BST) |
On Fri, 26 Oct 2007, mario wrote:
One of the biggest frustrations with the "sort" utility is figuring out how to
tell it where exactly the keys are on each line. For example, I have a file
which contains, in part,
MI#4617 ROM11 FAD_13 vss! vss! nmos L=0.18U W=0.69U
MI#4765 ROM0N FAD_11 vss! vss! nmos L=0.18U W=0.69U
MI#4749 ROM8N FAD_15 vss! vss! nmos L=0.18U W=0.69U
I took the liberty of re-wrapping the lines where it seemed appropriate.
I really want to sort FIRST on column 3, and then on the numeric part of
column 2. I would think that the sort command would be something like
sort -s -k3 -k2.4n
-k3 means "from key 3 until the end of the line". -k3,3 will restrict
just to the single field.
BUT this doesn't work. It sorts OK on column 3, but then does nothing
with the second sort key.
It would be incredibly useful if there were some mode in which sort
would just report each line and the sort keys found on that line, so
that I can make sure that I'm properly communicating how to find the
darn keys!
I agree, a debug mode for sort would be very useful.
Cheers,
Phil