![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Conditionally joining lines in vi | ifermon | UNIX for Dummies Questions & Answers | 0 | 06-04-2008 06:43 AM |
| Joining lines from two files - please help | chandra004 | Shell Programming and Scripting | 25 | 07-26-2006 11:39 PM |
| Joining 3 lines at a time | Sabari Nath S | Shell Programming and Scripting | 14 | 12-20-2005 10:29 PM |
| Joining multiple lines | beilstwh | Shell Programming and Scripting | 4 | 03-02-2005 02:51 AM |
| Joining lines in log file | bubba112557 | Shell Programming and Scripting | 3 | 05-18-2004 04:10 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Joining 2 lines in a file together
Hi guys,
I've got a log file which has entries that look like this: ------------------------------------------------------------------------------- 06/08/04 07:57:57 AMQ9002: Channel program started. EXPLANATION: Channel program 'INSCCPQ1.HSMTSPQ1' started. ACTION: None. ------------------------------------------------------------------------------- I need a script which will extract the error code and date and display the results like this: 06/08/04 07:57:57 AMQ9002: Channel program started. So basically it joins the date and AMQ code lines together and then greps on AMQ. The error code ALWAYS starts with AMQ. Can anyone offer any suggestions on if that can be done? Thanks Gareth |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
something to start with:
nawk -f m22.awk logFile this is m22.awk: Code:
BEGIN {
FS=RS=""
}
$1 ~ /^[0-9]/ {
print $1 " " $2
}
|
|
#3
|
|||
|
|||
|
awk '{ if ($1 ~ /^[0-9]/) { Ln=$0;getline;print Ln" "$0 }}' <filename> will do it
|
|
#4
|
|||
|
|||
|
thank you, thank you, this works a treat. I'd buy you a pint if you were local!
|
|||
| Google The UNIX and Linux Forums |