Skip to content

Instantly share code, notes, and snippets.

@dewomser
Last active November 5, 2025 11:52
Show Gist options
  • Select an option

  • Save dewomser/37bee8b04be32a985489ee65cbdadd30 to your computer and use it in GitHub Desktop.

Select an option

Save dewomser/37bee8b04be32a985489ee65cbdadd30 to your computer and use it in GitHub Desktop.
Get temperature from an API. Decide if hot or cold. A very short Bashscript
#!/bin/bash
# Es geht auch ohne Variable a
t=$(curl -s https://wetter.hs-worms.de/api/v3/data | jq '.temperature.out')
t1=15
if [[ $t < $t1 ]]; then echo "Uh, this is cold !"; else echo "Uff,rather warm !"; fi
#!/bin/bash
t=$(curl -s https://wetter.hs-worms.de/api/v3/data | jq '.temperature.out')
t1=15
a=$(echo "$t<$t1"|bc)
#testa failed =$(( t<t1 ))
if [[ $a -eq 1 ]]; then
echo "Uh, this is cold !"
else
echo "Uff,rather warm !"
fi
@wader
Copy link

wader commented Nov 4, 2025

jq can help out also

$ curl -s https://wetter.hs-worms.de/api/v3/data | jq -r 'if .temperature.out < 15 then "Uh, this is cold !" else "Uff,rather warm !" end'
Uff,rather warm !

@dewomser
Copy link
Author

dewomser commented Nov 5, 2025

Vielen Dank für den Tipp 😃

jq can help out also

$ curl -s https://wetter.hs-worms.de/api/v3/data | jq -r 'if .temperature.out < 15 then "Uh, this is cold !" else "Uff,rather warm !" end'
Uff,rather warm !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment