How to read .xml to output an specific number?

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Hello I’ve been using this:

curl -s “http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric” -o ~/.cache/weather.xml

to write a weather.xml file in my cache folder. the output is this. the problem is that it’s only in 1 line and I’m trying to use grep to get an output of the icon value of today:

{“cod”:”200″,”message”:0,”cnt”:40,”list”:[{“dt”:1574629200,”main”:{“temp”:12.8,”temp_min”:12.8,”temp_max”:13.07,”pressure”:1020,”sea_level”:1020,”grnd_level”:1012,”humidity”:82,”temp_kf”:-0.27},”weather”:[{“id”:804,”main”:”Clouds”,”description”:”overcast clouds”,”icon”:”04n”}]

which in this case is “04n” so I can use something like this:

~/.weather-icons/$(grep “icon” ~/.cache/weather.xml).png

that would output ~/.weather-icons/04n.png so I can use the icon from my folder with the same name as the icon value to display in conky using $image. My question is how can i get this done? I don’t know if there is a better command to read a file.xml using the parameters shown here or if there is a way I can use grep to just output the icon value. Thanks

X ITM Cloud News

Marisa

Next Post

Ubuntu 19.10 Live USB Issues on Mac (Stuck on Loading Screen)

Sun Nov 24 , 2019
Spread the love          I am trying to install Ubuntu 19.10 on my MacBook Pro (2019) and I have encountered a few issues. I successfully installed Ubuntu 18.04 after a bit of working through issues. I burned the Ubuntu ISO onto a USB using Etcher and I am using Mac’s regular boot […]
X- ITM

Cloud Computing – Consultancy – Development – Hosting – APIs – Legacy Systems

X-ITM Technology helps our customers across the entire enterprise technology stack with differentiated industry solutions. We modernize IT, optimize data architectures, and make everything secure, scalable and orchestrated across public, private and hybrid clouds.

This image has an empty alt attribute; its file name is x-itmdc.jpg

The enterprise technology stack includes ITO; Cloud and Security Services; Applications and Industry IP; Data, Analytics and Engineering Services; and Advisory.

Watch an animation of  X-ITM‘s Enterprise Technology Stack

We combine years of experience running mission-critical systems with the latest digital innovations to deliver better business outcomes and new levels of performance, competitiveness and experiences for our customers and their stakeholders.

X-ITM invests in three key drivers of growth: People, Customers and Operational Execution.

The company’s global scale, talent and innovation platforms serve 6,000 private and public-sector clients in 70 countries.

X-ITM’s extensive partner network helps drive collaboration and leverage technology independence. The company has established more than 200 industry-leading global Partner Network relationships, including 15 strategic partners: Amazon Web Services, AT&T, Dell Technologies, Google Cloud, HCL, HP, HPE, IBM, Micro Focus, Microsoft, Oracle, PwC, SAP, ServiceNow and VMware

.

X ITM