0

I am using Nerdtool on and iMac running OSx 10.6.8 and have written some code to get a weather report and display it on my desktop. How do I delete the text after the last period beginning with "Forcast issued"? A second issue I noticed is that the text returned has a 'space' in front of the first character. I'd like that gone too. Below is the command and output I get using Terminal. Thanks.

Command:

curl --silent "http://weather.gc.ca/rss/city/on-137_e.xml" | grep -E '(Weather Forecasts:|</summary)'| head -3 | sed -e 's/<summary type=\"html\">//' -e 's/<\/summary>//' -e 's/]]> //' -e 's/No watches or warnings in effect. //'

Output:

Sunny this morning then a mix of sun and cloud with 40 percent chance of showers this afternoon. Risk of a thunderstorm this afternoon. Wind becoming west 20 km/h this afternoon. High 29. UV index 8 or very high. Forecast issued 05:00 AM EDT Friday 31 July 2015

Irvin
  • 23
  • 2
  • this is very broad. Provide a representative sample input, define clearly what is your desired output and show -also clearly- what you tried. You may want to read [ask]. – fedorqui Jul 31 '15 at 14:55
  • You may also want to see, "What should I do when someone answers my question?": http://stackoverflow.com/help/someone-answers – Qualia Aug 01 '15 at 13:19
  • @fedorqui. I think I clearly stated what my goals where, providing both my code and the output produced by it. The quick and accurate reply by nathan I think supports that. – Irvin Aug 01 '15 at 22:31

1 Answers1

0

You already know how to use sed s to delete text. You can target the front of the line with ^ and the end of the line with $. So you can delete the space at the beginning with: -e 's/^ //' And delete Forecast issued to the end of the line with: -e 's/ Forecast issued.*$//'

Nathan Wilson
  • 856
  • 5
  • 12