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?
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.
[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)
i don't want to catch occurences of where select is part of word, (e.g. selection)
i want to catch when select is the only word on the line.
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;}'