sort filecontent by date

sort filecontent by date

Post by Niclas Mor » Fri, 19 Jan 2001 04:13:34



Hi folks,

I have a file with several thousands lines, consists of several parts of
10-20 lines. One of these 10-20 lines is the date in the format
"DATE:01-Jan-2001"

The first line in each part always starts with "KEY:", and finish with
"<<EOD>>"
I am looking for some way to pull out all 10-20 lines with date
including Jan-2001 into a separat file, and all 10-20 lines including
date Dec-2000 into another file, Nov-2000 into yet another file, and so
on...

Anyone have any clue how to do this?

T.I.A
  - Niclas

 
 
 

sort filecontent by date

Post by David B. Chorli » Fri, 19 Jan 2001 06:48:59



Quote:>Hi folks,
>I have a file with several thousands lines, consists of several parts of
>10-20 lines. One of these 10-20 lines is the date in the format
>"DATE:01-Jan-2001"
>The first line in each part always starts with "KEY:", and finish with
>"<<EOD>>"
>I am looking for some way to pull out all 10-20 lines with date
>including Jan-2001 into a separat file, and all 10-20 lines including
>date Dec-2000 into another file, Nov-2000 into yet another file, and so
>on...
>Anyone have any clue how to do this?

Here's a [ng]awk approach:
Start saving lines when you see the  "KEY:"
Get the proper file for output when you see the "DATE"
Flush the lines when you see "<<EOD>>"

Is it enough of a clue?  You'll probably want to use split()
to get the right file name out of the "DATE" line.

Quote:>T.I.A
>  - Niclas

--
David B. Chorlian
Neurodynamics Lab  SUNY/HSCB



 
 
 

1. Sorting dates w "sort" [Q]

    Hello everybody,

  Do you know a sipmle way to sort a file with dates by "sort" (UNIX).
 I need to sort smth like

 Feb 17
 Mar  19
 Dec  1
 Dec 4
 Dec 2
 Jan 22

     etc...

  (all this is embedded into a dozen of other columns).

 The problem is that the -M option does not care about digits, all other
 options do not care about the month order...


 thanx

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Igor L. Markov                 * *         Glue your shoes to the ceiling.
  UCLA, Department of Mathematics *  Lie down on the floor barefoot beneath
  Los Angeles, CA 90024-1555     * * the shoes before your roomate comes in
  Phone: (310)-794-3447 (home)    *   and as they enter, slowly sit up, rub-

                                  *                                incident.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. Trident CyperBlade 3d/MVP4 on Compaq presario

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

4. System "noise" pauses system

5. Knode sort on date broken

6. video editing on linux?

7. Sort on Date question

8. sco unix ingres

9. how to sort the mbox by date

10. Sorting files into directories by date

11. need help sorting a list on date *

12. sort by date

13. Sort by First Date Field (MM/DD/YY)