I posted this in
dBforums > Usenet Groups > comp.unix.* > comp.unix.shell,
I figure someone might be able to help me here instead.
I need a script to combine lines. Dont know the set amount of lines, for ex, the text in the file is:
082404 23:12:59
[ Event blah1 blah 2 blah 4 ]
(path) /etc/temp
082404 23:22:60
[ Event blah1 blah 2 blah 4 ]
082404 23:32:12
[ Event blah1 blah 2 blah 4 ]
(path) /etc/temp/dff/sdf
....
....
....
and so on. I need it to look like this after the script:
082404 23:12:59 [ Event blah1 blah 2 blah 4 ] (path) /etc/temp
082404 23:22:60 [ Event blah1 blah 2 blah 4 ]
082404 23:32:12 [ Event blah1 blah 2 blah 4 ] (path) /etc/temp/dff/sdf
....
....
Basically, puts those 3 elements into 1 line, however there might not always be a path. I think I need to use the awk command? But I'm not familar with using the awk command. Thanks in advance!
this is what i tried:
the text file is temp and this is what i typed:
awk '{$line1 = $0; getline $line2; getline $line3; print $line1, " ", $line2, " ", $line3}' temp
and the output is:
082404 23:12:59 082404 23:12:59 082404 23:12:59
082404 23:22:60 082404 23:22:60 082404 23:22:60
[ Event blah1 blah 2 blah 4 ] [ Event blah1 blah 2 blah 4 ] [ Event blah1 blah 2 blah 4 ]
although it isnt exactly what i want, i just need some if statements in there, it seems like $line2 and $line3 are getting the same value as $line1, why is that? Thanks