Sort arguments

Sort arguments

Post by Fr€d » Sat, 07 Dec 2002 08:09:26



I need to sort a file on the first character in the 4th field, then the
third field then the 2nd field.

I used
  sort -y -k 4.1,4.1 -k 3,3 -k 2,2n

but I don't get the proper sort on the first character

example data
1213  1995031311483766 00000000   CX8440 0033105 10140Q0 1000     35.2
1313  1995031311483766 00000000   CX8440 0033105 10140Q0 2000     33.2
1413  1995031311483766 00000000   CX8440 0033105 10140Q0 2000     38.5
1513  1995031311483766 00000000   CX8440 0033105 10140Q0 2000     25.2
1613  1995031311483766 00000000   CX8440 0033105 10140Q0 3000     35.2
2310  1997031109572954 00000000   MX7960 9700088 20078Q0 1000     52.5
2310  1997031109572954 00000000   MX7960 9700088 20078Q0 2000     61.5
2310  1997031109572954 00000000   MX7960 9700088 20078Q0 2000     62.5
2501  1997031109584497 00000000   MX7960 9700088 20119T0 1000     56
2501  1997031109584497 00000000   MX7960 9700088 20119T0 1000     56
1313  1998111511575346 00000000   CX8440 0033000 40027Q0 3000     23.3
1313  1998111911594098 00000000   CX8440 0033000 90169Q0 1500     22.5
1313  1998122711594032 00000000   CX8440 0033000 90111Q0 2000     26.5
1313  1998122711594032 00000000   CX8440 0033000 90111Q0 3600     22.5
2302  1994010710525257 0000000000 CX5380 0141684 20030Q0 1000     60
2302  1994010710525257 0000000000 CX5380 0141684 20030Q0 1000     60
2302  1994010710525257 0000000000 CX5380 0141684 20030Q0 1000     60

This sample comes out exactly as it goes in, when I really want all the
'C's sorted
before all the 'M' in the fourth field.  I must be missing something,
but I haven't been
able to come up with it.  Is the multiple spaces between the 3rd and 4th
fields messing this up?
(not according to man sort:  "The default field separator is one or more
spaces.")

thanks

 
 
 

Sort arguments

Post by Fr€d » Sat, 07 Dec 2002 09:12:54



> I need to sort a file on the first character in the 4th field, then the
> third field then the 2nd field.

> I used
>   sort -y -k 4.1,4.1 -k 3,3 -k 2,2n

> but I don't get the proper sort on the first character
> This sample comes out exactly as it goes in, when I really want all the
> 'C's sorted
> before all the 'M' in the fourth field.  I must be missing something,
> but I haven't been
> able to come up with it.  Is the multiple spaces between the 3rd and 4th
> fields messing this up?
> (not according to man sort:  "The default field separator is one or more
> spaces.")

> thanks

Never mind, when I added the -b argument I got what I wanted; it is
related to the length of the third field and the number of spaces.

thanks

 
 
 

1. sort sort: 0653-657 A write error occurred while sorting (4.1.3)

On a 4.1.3 system, we intermittently are seeing:

sort: 0653-657 A write error occurred while sorting

There is nothing in errpt, and the destination file system of
the sort is certainaly not full.

Does anyone have any suggestions as to what this could mean?

Thanks.

p.s. the actual sort operation is:

sort -d -f -u +0 -1 +1 -2 funds.load | awk '
  { printf "%s %s %s\n", $1, $2, $3 }' >funds.sorted

 *or it might be* :

sort -d -f -u +0 -1 acc_codes.update >acc_codes.sorted

(this is not my code, and I'm not familiar with its design).

Thanks,

--

2. Free Solaris7 as a learning tool

3. sort: write error while sorting: No space left on device??

4. Wanted: Irix5 toolchest port

5. "sort" sorting uppercase/lowercase differently on different boxes

6. Serial C Programming Help!

7. Sorting without "sort" ?

8. Need Help with "cron"

9. default secondary sort line in 'sort'

10. (sort | uniq) vs (sort -u)

11. bash - sort command - can I sort by a certain field?

12. How to have sort start sorting froma given column?

13. Why does sort or GNU sort (v1.5) perform like this?