Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to find the current weather of a particular city or my location from terminal.Is there any command-line weather app?

share|improve this question

4 Answers 4

up vote 8 down vote accepted

Search for your city at http://www.accuweather.com and replace the URL in the following script with the URL for your city:

#!/bin/sh

URL='http://www.accuweather.com/en/de/berlin/10178/weather-forecast/178087'

wget -q -O- "$URL" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $2": "$16", "$12"°" }'| head -1

Sample output:

Berlin, Germany: Foggy, 1°
share|improve this answer

I have got one more way .

Open your .bashrc file and then paste this code at the bottom

weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-<YOURZIPORLOCATION>}"|perl -ne '/<title>([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';}

Then save & close your .bashrc file.

now type bash to update the file.

then type

weather <location name>

for example

august@august-OEM:~$ weather guntur
December 14, 2013: Clear. High 31&amp;deg;C (87&amp;deg;F). Winds 0 kph North
December 15, 2013: Clear. High 29&amp;deg;C (84&amp;deg;F). Winds 10 kph NNW
December 16, 2013: Clear. High 31&amp;deg;C (87&amp;deg;F). Winds 10 kph North
December 17, 2013: Clear. High 29&amp;deg;C (84&amp;deg;F). Winds 7 kph ENE
December 18, 2013: Scattered Clouds. High 29&amp;deg;C (84&amp;deg;F). Winds 3 kph ENE
December 19, 2013: Scattered Clouds. High 29&amp;deg;C (84&amp;deg;F). Winds 3 kph ENE
share|improve this answer
1  
Nice with weather forecast. +1 from me. –  souravc Dec 15 '13 at 5:48

First you need to install the weather-util package, to do that just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo apt-get install weather-util

You’ll need your local weather code.

After installation you can run weather -i <code>. The code you get from the link above. For a list of available options, you can run weatherWeather info

share|improve this answer
    
it shows Last updated Dec 11, 2013 - 07:00 AM EST / 2013.12.11 1200 UTC Temperature: 86 F (30 C).is there no way to know the current weather. –  Avinash Raj Dec 13 '13 at 17:13
    
Depending on your location that could be the current info that's available. –  Mitch Dec 13 '13 at 17:15

Although accuweather curl solution is pretty good I needed something more informational, so I created simple bash script that pulls info for next 4 hrs from weather.com website. As in previous example you have to modify link for your location.

Example output:
$ ./getWeather.sh
Temperature for 1 AM : 65&deg;F and outside should be: Partly - Cloudy FEELS LIKE:   65&deg;
Temperature for 2 AM : 65deg;F and outside should be: Partly - Cloudy FEELS LIKE: 65deg;
Temperature for 3 AM : 63deg; and outside should be: Partly - Cloudy FEELS LIKE: 63deg;
Temperature for 4 AM : 62deg; and should be: Mostly - Clear FEELS LIKE: 62deg;

Full script is located at: https://sites.google.com/site/wozoopalinux/home/wzbash001/get-weather-information-from-command-line-for-next-4-hrs

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.