Skip to content

Instantly share code, notes, and snippets.

@komasaru
Last active January 28, 2019 01:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save komasaru/9635884 to your computer and use it in GitHub Desktop.
Save komasaru/9635884 to your computer and use it in GitHub Desktop.
Bash script to get a METAR information.
#!/bin/bash
# 引数(ICAO コード)不正なら終了
if [[ ! "$1" =~ [0-9A-Z]{4} ]]; then
echo "Wrong argument!"
exit
fi
# URL("decode" データ)(以下のどちらか)
URL="http://weather.noaa.gov/pub/data/observations/metar/decoded/"
#URL="ftp://tgftp.nws.noaa.gov/data/observations/metar/decoded/"
# METAR 取得(以下のどちらか)
wget -q -O - "${URL}${1}.TXT"
#curl "${URL}${1}.TXT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment