![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to concatenate consecutive lines | shivi707 | UNIX Desktop for Dummies Questions & Answers | 1 | 01-12-2009 09:08 AM |
| need to concatenate two lines if the line doesnt end with quotes | laxmi131 | UNIX for Advanced & Expert Users | 9 | 10-27-2008 07:22 AM |
| concatenate and display 2 lines as 1 with a condition for 2 line ? | vithala | Shell Programming and Scripting | 7 | 07-11-2008 02:01 AM |
| Need solution concatenate and display 2 lines as 1 with a condition for 2 line ? | vithala | UNIX for Advanced & Expert Users | 1 | 07-10-2008 02:27 PM |
| Extracting Logfile Entries | harpdl | Shell Programming and Scripting | 2 | 07-13-2006 02:40 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Logfile - extracting certain lines to concatenate into 1 line
I've got a log file from automatic diagnostic runs. The log file is appended to each time an automatic log is run.
I'd like to just pull certain lines from each run in the log file, and concatenate them into 1 comma delimited line (for export into excel or an html table). Each diagnostic run is bracketed by a begin and end comment so I'm able to group it that way but I'm having trouble getting everything into 1 line. Typical data: Diags begin. Tues March 17 18:07:34 EDT 2009 PASS: (123) Power Check . . [more data] Diags end. Diags begin. Tues March 17 19:09:22 EDT 2009 FAIL: (123) Power Check . description: Voltage clamp . .[more failing data details] . Diags end. I want the timestamp, test result (for the 123 test) I was able to use awk to get close but I can't quite get it. awk '/Diags begin/{getline;print};{if ($2=="(123)") print $1,$2,$3,$4}' This gives me: Mon Mar 16 11:37:07 EDT 2009 PASS: (123) Power Check Mon Mar 16 12:31:10 EDT 2009 PASS: (123) Power Check Tue Mar 17 01:30:54 EDT 2009 **FAIL: (123) Power Check Tue Mar 17 03:08:16 EDT 2009 PASS: (123) Power Check What I'm trying to get is: Mon Mar 16 11:37:07 EDT 2009,PASS: (123) Power Check Mon Mar 16 12:31:10 EDT 2009,PASS: (123) Power Check Tue Mar 17 01:30:54 EDT 2009,**FAIL: (123) Power Check Tue Mar 17 03:08:16 EDT 2009,PASS: (123) Power Check Also, I'm looking for a way to just pull the information for a certain time frame (for instance the current date - 7 days) but I'll worry about that later.. baby steps... ![]() The system is Unix (HP-UX) so awk, perl, or sed are options. Thanks for any help.. Paul |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|