SED - adding blank line after each Range Match

the following range matching works great but i wish to add a blank line after each range result set... which i've tried and researched to no avail

MY INPUT DATA:

CURRENT CODE I'M USING:

 
sed -n '/[Ss][Ee][Ll][Ee][Cc][Tt][ ]*$/,/;/p' $INPUT_FILE

RESULTS I'M GETTING:

RESULT I looking to get: (see blank line after semicolumn)

I thank you in advance for your time.

-----Post Update-----

I found solution at:

Sorry for the trouble... didn't see that post until it came up as "helpfull thread" to my new post :frowning:

You could try something like this:

sed -n '
  /[Ss][Ee][Ll][Ee][Cc][Tt]/,/;/{/;/G;p;}
  ' infile 

Some versions of sed support the I (for case Insensitive) flag:

sed -n '
  /select/I,/;/{/;/G;p}
  ' infile 

Awsome!...... in my quest to understand the hows and whys of SED, ( so as not to just be a coding monkey :)) could you explaing the part in red

sed -n '/select/I,/;/{/;/G;p}

i beleive the p is to output the results and /;/G to add a blank line..
but I don't understand the purpose/usage of the construct { .... } and the ; between G & p

Can you help me understand so i can use this in the future?

PS: could you recommend a usefull sed book?

Thanks in advance for you help

The braces limit the scope of the following code to the previously matched records (the records that satisfy the range pattern).
So, the G command (append the hold space to the pattern space, in this case the hold space is empty so you get only the newline character)
will apply on for the records that match the pattern /;/ (the last line of your paragraph).

The only printed book I know is sed & awk by Dale Dougherty and Arnold Robbins.

You can begin with Bruce Barnett's sed tutorial.

[quote="radoulov,post:4,topic:242130"]
The braces limit the scope of the following code to the previously matched records (the records that satisfy the range pattern).
So, the G command (append the hold space to the pattern space, in this case the hold space is empty so you get only the newline character)
will apply on for the records that match the pattern /;/ (the last line of your paragraph).

quote]

i understand that the /;/ as part of /;/G means that newline will go after the semicolum... BUT...

i'm refering to the following semicolum , between the G and p

 
{/;/G;p} 

Also..... if {coding} limits the scope to the previous command.... is that the same as using the -e to apply code to just previously execute expression?

 
sed -e '/select/I,/,/;/!d' -e '/;/G'

Thanks again for your patience with my questions.

-----Post Update-----

Thanks, the first worked, but the /I,/ didn't work...

but i had to add back after the select *$ because: (which works for 1 & 2 below but not 3)

  1. i don't want to catch occurences of where select is part of word, (e.g. selection)

  2. i want to catch when select is the only word on the line.

  3. i want to catch when select is not the only word on the line, and is followed by a space

***** see that i've modified the test data to show you *****

 
sed -n '/[Ss][Ee][Ll][Ee][Cc][Tt][ ]*$/,/;/{/;/G;p;}'

Some sed implementations support word boundaries:

/\<[Ss][Ee][Ll][Ee][Cc][Tt]\>/

Or just use a more powerful tool (e.g. Perl).