The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 07-17-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Here it is again with comments

Code:
awk '
    # for every line containing just a ";"
    /^;$/ {
        # read subsequent lines until we reach another one containing
        # just a ";"
        while (getline && $0 !~ /^;$/) {
            # print them
            print
        }
        # exit from the script (i.e. do not process any more lines)
        exit
    }
' inputfile > outputfile
To satisfy your new requirement you only need to modify the script slightly to search for different strings instead of ";".