join a range of lines using awk/sed 
Author Message
 join a range of lines using awk/sed

Subject: Re: join a range of lines using awk/sed
Keywords: awk, sed
Date: 22 Sep 92 21:30:40 GMT

>       awk:
>               /A:/,/B:/ {
>                       gsub("\n", "")
>                       print
>               }

If the IRS is newline, you cannot use gsub to strip the newline because
is not there, that is, $0 does not contain a newline. If ORS is newline,
then the newlines are added by print. Use printf to control when
newlines are
added, as in

/A:/,/B:/ { if( $0 ~ /B:/ ) printf( "\n%s\n", $0 );
            else printf( "%s ", $0 );


{ print; # this prints the lines that do not match above }

Hope that helps.

Sun, 16 Feb 2003 21:12:14 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Question: How to remove END OF LINE using AWK or SED

2. Sed/AWK - replace positions in multiple lines.

3. Extracting hyphenated words using sed/awk

4. Using awk And/Or sed To Edit Fourth Field Of File

5. how to insert a comma using either sed or awk

6. extracting top 100 data using awk or sed/perl

7. Q: Directory highlighting using sed/awk?

8. deleting records in a file using AWK, SED, or kshell

9. deleting records using AWK, SED, etc.

10. Using awk & sed from tcl/tk

11. Ranges in AWK (file name is two lines down)

12. Join multiple lines of records to single line


Powered by phpBB® Forum Software