print out the continuation line 
Author Message
 print out the continuation line

Hi, if anyone can send a little help on how to print out the first two
lines.

CONM2     256629  225350 0 0.098   0.0     0.0     0.0  +CNM   0
+CNM   0 0.0     0.0     0.0     0.0     0.0     0.0
CONM2     256630  225344 0 0.098   0.0     0.0     0.0
CORD2C         2        2428.802-383.91
922.12612520.935-387.763960.8119+C2R   0
+C2R   02467.487-384.685829.9154

I would like to use awk to do:

search for line with CONM2 at the beginning. And if this line contains
character + also then print out this line and the line after it. By
the way the line after it has "+" common. My essential task is when I
recognize a line how to tell awk to print the NR+1 line? that the
program has not read in yet ?

thanks.



Wed, 06 Jul 2005 02:19:12 GMT  
 print out the continuation line


Quote:
> Hi, if anyone can send a little help on how to print out the first two
> lines.

> CONM2     256629  225350 0 0.098   0.0     0.0     0.0  +CNM   0
> +CNM   0 0.0     0.0     0.0     0.0     0.0     0.0
> CONM2     256630  225344 0 0.098   0.0     0.0     0.0
> CORD2C         2        2428.802-383.91
> 922.12612520.935-387.763960.8119+C2R   0
> +C2R   02467.487-384.685829.9154

> I would like to use awk to do:

> search for line with CONM2 at the beginning. And if this line contains
> character + also then print out this line and the line after it. By
> the way the line after it has "+" common. My essential task is when I
> recognize a line how to tell awk to print the NR+1 line? that the
> program has not read in yet ?

> thanks.

#!/usr/bin/awk -f
(/^CONM2/) && ($0 ~ /\+/) {
print $0
if ($0 ~ /\+/)
  getline
print $0

- Show quoted text -

Quote:
}



Wed, 06 Jul 2005 04:27:43 GMT  
 print out the continuation line

Quote:


> > Hi, if anyone can send a little help on how to print out the first two
> > lines.

> > CONM2     256629  225350 0 0.098   0.0     0.0     0.0  +CNM   0
> > +CNM   0 0.0     0.0     0.0     0.0     0.0     0.0
> > CONM2     256630  225344 0 0.098   0.0     0.0     0.0
> > CORD2C         2        2428.802-383.91
> > 922.12612520.935-387.763960.8119+C2R   0
> > +C2R   02467.487-384.685829.9154

> > I would like to use awk to do:

> > search for line with CONM2 at the beginning. And if this line contains
> > character + also then print out this line and the line after it. By
> > the way the line after it has "+" common. My essential task is when I
> > recognize a line how to tell awk to print the NR+1 line? that the
> > program has not read in yet ?

> > thanks.

> #!/usr/bin/awk -f
> (/^CONM2/) && ($0 ~ /\+/) {
> print $0
> if ($0 ~ /\+/)
>   getline
> print $0
> }

Great ! simply amazing. I was wondering of the use of "getline" for a
while and now to see it in action. If I want to extend its general use
of getline to say ... get next 4 lines instead of just one, how would
I modify the getline to do it?

I thought that the use of array to store every line in the file first
and then use NR as a tracking device to request next line or next few
lines .. but it may be slower than using "getline".

Thanks.



Wed, 06 Jul 2005 11:21:33 GMT  
 print out the continuation line



Quote:


> > > Hi, if anyone can send a little help on how to print out the first two
> > > lines.

> > > CONM2     256629  225350 0 0.098   0.0     0.0     0.0  +CNM   0
> > > +CNM   0 0.0     0.0     0.0     0.0     0.0     0.0
> > > CONM2     256630  225344 0 0.098   0.0     0.0     0.0
> > > CORD2C         2        2428.802-383.91
> > > 922.12612520.935-387.763960.8119+C2R   0
> > > +C2R   02467.487-384.685829.9154

> > > I would like to use awk to do:

> > > search for line with CONM2 at the beginning. And if this line contains
> > > character + also then print out this line and the line after it. By
> > > the way the line after it has "+" common. My essential task is when I
> > > recognize a line how to tell awk to print the NR+1 line? that the
> > > program has not read in yet ?

> > > thanks.

> > #!/usr/bin/awk -f
> > (/^CONM2/) && ($0 ~ /\+/) {
> > print $0
> > if ($0 ~ /\+/)
> >   getline
> > print $0
> > }

> Great ! simply amazing. I was wondering of the use of "getline" for a
> while and now to see it in action. If I want to extend its general use
> of getline to say ... get next 4 lines instead of just one, how would
> I modify the getline to do it?

> I thought that the use of array to store every line in the file first
> and then use NR as a tracking device to request next line or next few
> lines .. but it may be slower than using "getline".

> Thanks.

Wrap getline within a "for" loop.....


Wed, 06 Jul 2005 15:51:49 GMT  
 print out the continuation line


Quote:



> > Hi, if anyone can send a little help on how to print out the first
two
> > lines.

> > CONM2     256629  225350 0 0.098   0.0     0.0     0.0  +CNM   0
> > +CNM   0 0.0     0.0     0.0     0.0     0.0     0.0
> > CONM2     256630  225344 0 0.098   0.0     0.0     0.0
> > CORD2C         2        2428.802-383.91
> > 922.12612520.935-387.763960.8119+C2R   0
> > +C2R   02467.487-384.685829.9154

> > I would like to use awk to do:

> > search for line with CONM2 at the beginning. And if this line
contains
> > character + also then print out this line and the line after it. By
> > the way the line after it has "+" common. My essential task is when
I
> > recognize a line how to tell awk to print the NR+1 line? that the
> > program has not read in yet ?

> > thanks.

> #!/usr/bin/awk -f
> (/^CONM2/) && ($0 ~ /\+/) {
> print $0
> if ($0 ~ /\+/)
>   getline
> print $0
> }

The if() is redundant - you already know if $0 matches a +

HTH
--
Peter S Tillier
"Who needs perl when you can write dc and sokoban in sed?"



Wed, 06 Jul 2005 16:44:41 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Print outs of Richtext Streams

2. Using FS for new line continuation.

3. Continuation lines in Eiffel Source

4. line continuation problems or ....?

5. NT Regina REXX Line Continuation Error

6. File reading and line continuation with '\'

7. line continuation

8. Block formatting (was: line continuation)

9. How is a line continuation done???

10. how to do a line continuation ???

11. what's about line continuation in TASM ?

12. Line Continuation in ASM

 

 
Powered by phpBB® Forum Software