Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 14 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

Simply enter the following in a terminal:

curl wttr.in/your_location

For example, for Tehran:

curl wttr.in/tehran

Which gives you:

Sample output

share|improve this answer
1  
Way much better ! – Stuffix May 13 at 21:33

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

Here's a great semi-graphical command line utility written in Go:

https://github.com/schachmat/wego/

You'll need to install Go and setup some API stuff, but the instructions are there. Here's a sample pic:

enter image description here

share|improve this answer
2  
This is being publicly hosted now - with IP address to region mapping. Try: curl -4 wttr.in – jschrab Feb 24 at 21:56
    
@jschrab: And you don't need -4 actually. curl wttr.in is enough – Igor Chubin Feb 24 at 22:25

Try using

telnet rainmaker.wunderground.com
share|improve this answer

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
1  
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
    
I just tried this and discovered that it is easier to use now: weather YOURLOCATIONNAME It searches for your location then and provides possibly multiple results. From these you can read the station identifier which you can use as argument to fetch your weather informations from – Nicolas Mar 22 at 23:05

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.