Need help using complex SORT in Korn Shell

Need help using complex SORT in Korn Shell

Post by p.. » Thu, 30 Oct 1997 04:00:00



I have a very bad data file and it look like this:

4567,34,89,19970528 12:45 am,abC123^F
4567,34,67,19970528 06:13 pm, waBc^M
[Abc23;^M
cdf^M
^M
^F
4567,34,67,19970528 12:29 am,cdf346^F
1234,78,67,19970529 08:08 am,BCab^F

There are 5 fields in the file, field separator = ',' and record
separator = '^F'.

The 1st and the 4th field are char type and I would like to do the
sorting on these 2 fields in the following order:

1. Sort the 4th field with the latest date 1st record followed by the
related record (because the 1st field need to be group together in the
same group) starting from the oldest date and go in ascending order.
2. Group the 1st field in the same group,(i.e., below)

Base on the input above, the output should look like this:

1234,78,67,19970529 08:08 am,BCab^F
4567,34,67,19970528 06:13 pm, waBc^M
[Abc23;^M
cdf^M
^M
^F
4567,34,67,19970528 12:29 am,cdf346^F
4567,34,89,19970528 12:45 am,abC123^F

Please help.

 
 
 

1. Need help using complex SORT in Korn Shell

I have a very bad data file and it look like this:

4567,34,89,19970528 12:45 am,abC123^F
4567,34,67,19970528 06:13 pm, waBc^M
[Abc23;^M
cdf^M
^M
^F
4567,34,67,19970528 12:29 am,cdf346^F
1234,78,67,19970529 08:08 am,BCab^F

There are 5 fields in the file, field separator = ',' and record
separator = '^F'.

The 1st and the 4th field are char type and I would like to do the
sorting on these 2 fields in the following order:

1. Sort the 4th field with the latest date 1st record followed by the
related record (because the 1st field need to be group together in the
same group) starting from the oldest date and go in ascending order.
2. Group the 1st field in the same group,(i.e., below)

Base on the input above, the output should look like this:

1234,78,67,19970529 08:08 am,BCab^F
4567,34,67,19970528 06:13 pm, waBc^M
[Abc23;^M
cdf^M
^M
^F
4567,34,67,19970528 12:29 am,cdf346^F
4567,34,89,19970528 12:45 am,abC123^F

Please help.

2. Branching in SCCS

3. Pentium II and warning message

4. Need Help writing a complex Korn Shell Script

5. pthread_mutex_lock fails

6. Newbie help with Shell scripts (using Korn shell)

7. eth0 locks up on redhat7.0 w/ Athlon on reboot or shutdown

8. quoting complex strings in Korn Shell problem

9. Korn shell help with remote shell needed!

10. best korn shell resources and is there a korn shell faq

11. I need help in Korn Shell

12. SYSOUT & ERROR Logging in Korn Shell - Help Needed!