From: shulamitm on 6 Jun 2010 04:59 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 6 Jun 2010 06:29 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 6 Jun 2010 06:50 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!
|
Pages: 1 Prev: getenv set/putenv in multithread program Next: ANN: Seed7 Release 2010-06-06 |