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 -->
  #2 (permalink)  
Old 06-08-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,944
I'm assuming the horizontal lines aren't actually in the file, and are just used instead of
Code:
code tags
Code tags are better because they preserve spacing.

Here's a script:
Code:
#!/bin/sh

SHOULDPRINT=1

function do_flush
{
        if [[ ${SHOULDPRINT} -eq 1 && ! -z ${OUT} ]]
        then
                echo "${OUT}"
        fi
}

while read LINE
do
        if [[ -z ${LINE} ]]
        then
                do_flush
                OUT=""
                SHOULDPRINT=1
        elif    echo "${LINE}" | egrep -q "CONNECT|alter system switch logfile"
        then
                SHOULDPRINT=0
        else
                if [[ -z ${OUT} ]]
                then
                        OUT="
${LINE}"
                else
                        OUT="${OUT}
${LINE}"
                fi
        fi
done
do_flush