How to sort on exactly one field only

Anand Venkata Raman ARaman at massey.ac.nz
Wed Oct 24 07:21:04 AEST 1990


I want to sort a file exclusively on field #2.
For example,
A portion of the file looks like
appl1  3  Submitted
appl2  4  Submitted
appl1  3  Started
appl3  5  Submitted
appl2  4  Started
appl1  3  Finished(0)
appl2  4  Finished(7)
appl3  5  Started
appl3  5  Finished(3)

I want all applications with the same jobID (Second field) grouped together
and the whole file sorted by jobID.  Sort does that fine.  But within a single
jobID, it sorts using the status as the secondary field which puts the Finished
record before the Started and Submitted.

I tried using sort +1 -2, but that doesn't seem to deter sort from looking
at field #3.

The man page says sort +pos1 -pos2 means the key field begins at pos1 and ends
before pos2.  But that doesn't seem to be the case.

Thanks for any help. (email)

- & (Anand)



More information about the Comp.unix.questions mailing list