?
Solved

unix sort question

Posted on 2010-03-26
2
Medium Priority
?
361 Views
Last Modified: 2013-12-26
I have the folllowing data.  I need to sort the date time field(1) and the job number last field and write to an ouput file, but I only want to sort the time field on the lines that have the "START" word

Input file:
22:54:42:444 ZEKE JOB START: job U1KC555
22:54:42:647 ZEKE JOB START: job U1KC000
22:54:43:647 ZEKE JOB EOJ: job U1KC555
22:54:43:647 ZEKE JOB START: job U1KC111
22:54:44:647 ZEKE JOB EOJ: job U1KC000
22:54:44:649 ZEKE JOB START: job U1KC999
22:54:45:647 ZEKE JOB EOJ: job U1KC111

output:

22:54:42:444 ZEKE JOB START: job U1KC555
22:54:43:647 ZEKE JOB EOJ: job U1KC555
22:54:42:647 ZEKE JOB START: job U1KC000
22:54:44:647 ZEKE JOB EOJ: job U1KC000
22:54:43:647 ZEKE JOB START: job U1KC111
22:54:45:647 ZEKE JOB EOJ: job U1KC111
22:54:44:649 ZEKE JOB START: job U1KC999

So  I'm trying to get the start and end of the jobs listed above and below each other, but I need to sort only on the START jobs
0
Comment
Question by:jbrajkovich
2 Comments
 
LVL 10

Expert Comment

by:lanboyo
ID: 28711451
Maybe someone can roll this into an awk one liner, but it seems like a non trivial problem.

I would make a bash or tcl script, I am sure someone who is good with perl would use that. Basically read the file one line at a time and if it is an end record read the next line. If it is a start record, output that, and look below this record one line at a time until you see an end record with a matching job id. output this record. Go on to the next record in the file.


Since the data seems to only have hours and seconds, will the files be limited by day in some way?  It looks like the records are always in order of occurrence,  do you really need to sort the data by time?
Will the job IDs always be unique? Are there only start and stop records? Is there a limit to how many lines will be in the file? The last question determines whether to load the file into memory or to use a temp file.
0
 

Accepted Solution

by:
jbrajkovich earned 0 total points
ID: 28711969
I figured this problem out thanks
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re involved with your company’s wide area network (WAN), you’ve probably heard about SD-WANs. They’re the “boy wonder” of networking, ostensibly allowing companies to replace expensive MPLS lines with low-cost Internet access. But, are they …
Make the most of your online learning experience.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question