sed: print out to first blank line

I am trying to use wget and sed to extract a text based weather forecast for the Greater Victoria area only, this is one paragraph of many in a web page. I have tried /^$/ but that does not seem to work. So far I get mostly what I want with this:

wget -qO - http://www.weatheroffice.gc.ca/forecast/textforecast_e
.html?Bulletin=fpcn11.cwvr | sed -n "/Greater Victoria/,/Fraser/p
"

but that stops one line ahead of what I want by using /Fraser/ . How can I change the sed portion of above to stop at what appears to be a blank line in the text?

Larry

I remember searching for a solution to a similar problem some years ago. When i finally found the answer it stunned me because of its simplicity. The trick is to simply quit sed when encountering the line on which you want to stop. Consider the following file:

# some text
# some text
# some text

# some other text
# some other text

If you want to stop at the blank line (for the purpose of the example we suppose it is completely empty) issue the following sed script:

sed '/^$/q' infile > outfile

Btw: my problem was to extract "headers" from script files. Usually a script has one or several lines at the beginning that start with a octothorpe ("#"). After these come lines with normal script code and then maybe the one or other commentary line starting with an octothorpe again. I wanted to extract only the first "header" lines, not any commentary after the first noncommentary line. My solution was analogous.

I hope this helps.

bakunin

Hi,

/1$/ won't do it as your text contains windows line-feeds (^M).
Try:

sed -n "/^Greater/,/^Fraser/{/^^M/{q};p}" F

To type a windows line-feed, press ctrl-v followd by ctrl-m.
Sed will stop printing when it encounters the first line starting with
a windows line-feed.

HTH Chris