[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to get sort keys to work

From: mario
Subject: Re: Trying to get sort keys to work
Date: Fri, 26 Oct 2007 10:49:08 -0700
User-agent: Thunderbird (X11/20070728)

Philip -

Thanks for responding to this.  The larger challenge seems to be pulling the number out of the 
second field.  I had hoped that -k2.4n would pull as much, numerically, out of the string as 
possible, but I'm just not certain what it's doing; I suspect that it's just bailing since 
sometimes the field has a trailing "N".  BTW, how do I say "from character 4 through 
the end of the field"?  Is -k2.4,2 appropriate?

-- Mario

Philip Rowlands wrote:
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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]