Joining lines in log file

Hi,

I need to develop a script to join multiple three lines in a log file into one line for processing with awk and grep. I looked at tr with no success. The first line contains the date time information. The second line contains the error line. The third line is a blank line.

Thanks,

Mike

Can you be more specific as to what you want done with your file? Also, please post a sample file (a few records) if you can.

A little script like

#!/bin/sh

awk 'BEGIN {
    RS="";
    FS="\n";
}
{ print $1 $2 }' some_log

will do what you want if I understand your question correctly.

If you want a blank space to seperate the two fields, just replace the print statement with print $1 " " $2

You will need to redirect the output to a suitable place, e.g.
myscript.sh > myscript.out

You could also do the same thing without awk:

#!/bin/sh

while read line
do
   if [ ! -z "$line" ]; then
       echo $line | tr '\n' ' '
   else
       echo ""
   fi
done < some_log

exit 0

Cheers
ZB
http://www.zazzybob.com

You could use the paste command, e.g....

$ cat file1
line one
line two
line three
line four
line five
line six
$ paste -d" " - - - < file1
line one line two line three
line four line five line six