Prev: vpath w/implicit pattern rule, & non-basename target (GNU make)
Next: grepping from last file of a listing......
From: shulamitm on 6 Jun 2010 05:01 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: superpollo on 6 Jun 2010 05:50 shulamitm ha scritto: > 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! if you dont mind the whitespace: ~/superpollo$ cat fields.sh #!/usr/bin/env bash while read A B do echo -n $A" " if [ -z "$B" ] then read B echo $B else echo $B fi done ~/superpollo$ cat fields ERROR1 1 ERROR2 1 WARNING1 0 WARNING2 0 WARNING3 0 ERROR3 1 ~/superpollo$ ./fields.sh < fields ERROR1 1 ERROR2 1 WARNING1 0 WARNING2 0 WARNING3 0 ERROR3 1 ~/superpollo$ bye -- Il valore 96 sarebbe,Volendo, un ipercubo in i.
From: shulamitm on 6 Jun 2010 06:35 On 6 ××× ×, 12:50, superpollo <ute...(a)esempio.net> wrote: > shulamitm ha scritto: > > > > > > > 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! > > if you dont mind the whitespace: > > ~/superpollo$ cat fields.sh > #!/usr/bin/env bash > while read A B > do >    echo -n $A" " >    if [ -z "$B" ] >    then >      read B >      echo $B >    else >      echo $B >    fi > done > ~/superpollo$ cat fields >   ERROR1     1 >   ERROR2     1 >   WARNING1    0 >   WARNING2 >   0 >   WARNING3 >   0 >   ERROR3       1 > ~/superpollo$ ./fields.sh < fields > ERROR1 1 > ERROR2 1 > WARNING1 0 > WARNING2 0 > WARNING3 0 > ERROR3 1 > ~/superpollo$ > > bye > > -- > Il valore 96 sarebbe,Volendo, un ipercubo in i.-×סתר ××§×¡× ×צ×××- > > -×ר×× ××§×¡× ×צ×××- thanks! how can I do the same in korn shell or c shell?
From: superpollo on 6 Jun 2010 06:44 shulamitm ha scritto: > On 6 יוני, 12:50, superpollo <ute...(a)esempio.net> wrote: >> shulamitm ha scritto: >> >> >> >> >> >>> 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! >> if you dont mind the whitespace: >> >> ~/superpollo$ cat fields.sh >> #!/usr/bin/env bash >> while read A B >> do >> echo -n $A" " >> if [ -z "$B" ] >> then >> read B >> echo $B >> else >> echo $B >> fi >> done >> ~/superpollo$ cat fields >> ERROR1 1 >> ERROR2 1 >> WARNING1 0 >> WARNING2 >> 0 >> WARNING3 >> 0 >> ERROR3 1 >> ~/superpollo$ ./fields.sh < fields >> ERROR1 1 >> ERROR2 1 >> WARNING1 0 >> WARNING2 0 >> WARNING3 0 >> ERROR3 1 >> ~/superpollo$ >> >> bye >> >> -- >> Il valore 96 sarebbe,Volendo, un ipercubo in i.-הסתר טקסט מצוטט- >> >> -הראה טקסט מצוטט- > > thanks! > how can I do the same in korn shell or c shell? beats me. i do not use them. but i think it will work ok at least in korn. bye
From: Ed Morton on 6 Jun 2010 08:18 On 6/6/2010 4:01 AM, 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==1 { if (p=="") { p=$0; next } else { $0=p$0; p="" } }1' file Ed.
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: vpath w/implicit pattern rule, & non-basename target (GNU make) Next: grepping from last file of a listing...... |