Created
April 8, 2019 19:51
-
-
Save dphiffer/19c15757f99c4708724699cdd53b7946 to your computer and use it in GitHub Desktop.
Shell script to print the current weekly mean value Mauna Loa CO2 value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prints the current weekly mean value Mauna Loa CO2 value, and | |
# compares it to the value from 365 days ago. | |
# Thanks to Pieter Tans <[email protected]> for data guidance. | |
url="ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_weekly_mlo.txt" | |
line=`curl -s $url | tail -n 1` | |
curr=`echo "$line" | cut -c 30-35` | |
year=`echo "$line" | cut -c 50-55` | |
diff=`echo "$curr - $year" | bc` | |
echo "Current Mauna Loa CO2: $curr ppm" | |
echo "365 days ago: $year ppm" | |
if [ "$diff" == "0" ] ; then | |
echo "→ no change since last year" | |
elif [[ $diff =~ ^- ]] ; then | |
echo "→ ${diff#-} ppm lower than last year" | |
else | |
echo "→ $diff ppm higher than last year" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see also: https://twitter.com/dphiffer/status/1115348317515460610