From: shulamitm on
Hello,

I'm looking for solution to the following problem:

I have a file contains 2 fileds, but in a few rows, the second field
go down (without spaces) to the next line.
How can I join the splitted lines?

For exmple:

I need to change the following :

ERROR1 1
ERROR2 1
WARNING1 0
WARNING2
0
WARNING3
0
ERROR3 1


To:



ERROR1 1
ERROR2 1
WARNING1 0
WARNING2 0
WARNING3 0
ERROR3 1

Thanks in advance!
From: pk on
shulamitm wrote:

> Hello,
>
> I'm looking for solution to the following problem:
>
> I have a file contains 2 fileds, but in a few rows, the second field
> go down (without spaces) to the next line.
> How can I join the splitted lines?
>
> For exmple:
>
> I need to change the following :
>
> ERROR1 1
> ERROR2 1
> WARNING1 0
> WARNING2
> 0
> WARNING3
> 0
> ERROR3 1
>
>
> To:
>
>
>
> ERROR1 1
> ERROR2 1
> WARNING1 0
> WARNING2 0
> WARNING3 0
> ERROR3 1
>
> Thanks in advance!

awk 'NF!=2{getline a; $0 = $0 "\t" a}1' file

replace "\t" with whatever you want to use as separator if tab is not ok.
From: shulamitm on
On 6 יוני, 13:29, pk <p...(a)pk.invalid> wrote:
> shulamitm wrote:
> > Hello,
>
> > I'm looking for solution to the following problem:
>
> > I have a file contains 2 fileds, but in a few rows, the second field
> > go down (without spaces)  to the next line.
> > How can I join the splitted lines?
>
> > For exmple:
>
> > I need to change the following :
>
> >    ERROR1         1
> >    ERROR2        1
> >    WARNING1      0
> >    WARNING2
> >    0
> >    WARNING3
> >    0
> >    ERROR3            1
>
> > To:
>
> >    ERROR1         1
> >    ERROR2        1
> >    WARNING1      0
> >    WARNING2       0
> >    WARNING3      0
> >    ERROR3            1
>
> > Thanks in advance!
>
> awk 'NF!=2{getline a; $0 = $0 "\t" a}1' file
>
> replace "\t" with whatever you want to use as separator if tab is not ok.-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

thanks a lot!