this is a BASHMETAR script and there is a mistake in the cloud section, i want the mistake fixed.
the full assignment:
create a series of regular expressions that identify different parts composing a METAR.
METARs are reports assembled with a particular format that is easy to decode with computer systems using regular expressions.
These reports typically come in two forms: North American METARs and International METARs. Create a series of regular expressions that decode each token of information using the North American METAR form.
You can find METAR reports at the following address:
http://weather.noaa.gov/weather/metar.shtml.
In order to find the weather information you need to get a METAR report from any airport you wish utilizing the appropriate code and then apply the different regular expressions to identify each token and eventually extract it from the report.
submission should be a script that reads a single line METAR from a file named: metar.txt
Your script output (to the shell screen) should include:
1. the report type: either METAR or SPECI for Special Report
2. the station identifies (four characters starting with a K)
3. Day of the month and time the report was filed
4. If the token AUTO is present, you should output This is a fully automated report
5. If the token COR is present, you should output This is a corrected observation
6. Wind direction and speed, wind gusting, and variable wind directions
7. Visibility in statute miles
8. Light, medium, or heavy rain (-RA|RA|+RA)
9. Cloud Conditions: [0 or more occurrences of each of the following]
a. Sky Clear
b. Few Clouds <altitude>
c. Scattered Clouds <altitude>
d. Broken Clouds <altitude>
e. Overcast Clouds <altitude>
10. Temperature
11. Dew Point
12. Barometric Pressure
13. If the token TH is present, you should output Thunderstorms reported in the areaum temperature for past 6 hours reported to nearest tenth of degree Celsius; reported on 00, 06, 12, 18 UTC reports; sn = 1 if temperature below 0oC and 0 if temperature 0oC or higher.
the script that needs to be fixed:
#!/bin/bash
token1=”AUTO”
token2=”COR”
METARFILE=”metar.txt”
VSM=$(egrep -o ‘s[[:digit:]]*SM’ $METARFILE | tr -d SM)
RAIN=$(egrep -o ‘?WRA’ $METARFILE | tr -d [:blank:])
CLOUD_SKC=$((`egrep o ‘SKC[[:digit:]]*?’ $METARFILE | cut -c4-6`*100))
CLOUD_FEW=$((`egrep o ‘FEW[[:digit:]]*?’ $METARFILE | cut -c4-6`*100))
CLOUD_SCT=$((`egrep o ‘SCT[[:digit:]]*?’ $METARFILE | cut -c4-6`*100))
CLOUD_BKN=$((`egrep o ‘BKN[[:digit:]]*?’ $METARFILE | cut -c4-6`*100))
CLOUD_OVC=$((`egrep o ‘OVC[[:digit:]]*?’ $METARFILE | cut -c4-6`*100))
TD_TEMP=$(egrep -o ‘[[:digit:]]{2}//?M[[:digit:]]{2}’ $METARFILE | cut -c1-2)
TD_DEW=$(egrep -o ‘[[:digit:]]{2}//?M[[:digit:]]{2}’ $METARFILE | tr -d M | cut -c4 5)
TH=$(egrep -o ‘sTHs’ $METARFILE | tr -d [:blank:] )
printf “Report type:tt”
egrep -o ‘METAR|SPECI’ $METARFILE
printf “Location:tt”
egrep -o ‘sK[A-Z]{3}s’ $METARFILE
DTGROUP=$(egrep -o ‘[[:digit:]]*Z’ $METARFILE)
day_of_month=$(echo $DTGROUP | cut -c1-2)
report_time_hour=$(echo $DTGROUP | cut -c3-4)
report_time_min=$(echo $DTGROUP | cut -c5-6)
printf “Day of month:tt%dn” $day_of_month
printf “Time:ttt%d:%dn” $report_time_hour $report_time_min
wind=$(egrep -o ‘[[:digit:]]*?G[[:digit:]]*KT’ $METARFILE)
wind_dir=$(echo $wind | cut -c1-3)
wind_spd=$(echo $wind | cut -c4-5)
wind_var=$(egrep -o ‘s[[:digit:]]V[[:digit:]]s’ $METARFILE)
wind_var1=$(echo $wind_var | cut -c1-3)
wind_var2=$(echo $wind_var | cut -c5-7)
printf “Wind direction:tt%d, Speed: %dn” $wind_dir $wind_spd
if [ “x$wind_var” != “x” ] ; then
printf “Wind direction is variable between %d and %dn” $wind_var1
$wind_var2
fi
printf “Visibility:tt%d Status Milesn” $VSM
if [ “$RAIN” == “+RA” ] ; then
printf “Heavy Rainn”
elif [ “$RAIN” == “RA” ] ; then
printf “Medium Rainn”
elif [ “$RAIN” == “-RA” ] ; then
printf “Light Rainn”
else
printf “n”
fi
printf “Cloud Conditions:ttn”
[ $CLOUD_SKC ] && printf “Clouds: ttSky clear, at %d feet above sea leveln”
$CLOUD_SKC
[ $CLOUD_FEW ] && printf $CLOUD_FEW
[ $CLOUD_SCT ] && printf
$CLOUD_SCT
[ $CLOUD_BKN ] && printf
leveln” $CLOUD_BKN
[ $CLOUD_OVC ] && printf
leveln” $CLOUD_BKN
“Clouds: ttA few, at %d feet above sea leveln”
“Clouds: ttScattered, at %d feet above sea leveln”
“Clouds: ttBroken clouds, at %d feet above sea
“Clouds: ttOvercast clouds, at %d feet above sea
printf “Temperature:tt%s degrees Celsiusn” $TD_TEMP
printf “Dew point:tt%s degrees Celsiusn” $TD_DEW
if [ “$TH” ] ; then
printf “Thunderstorms reported in the arean”
fi
if [ $(egrep -o “$token1>” $METARFILE) ] ; then
printf “This is a fully automated reportn”
fi
if [ $(egrep -o “$token2>” $METARFILE) ] ; then
printf “This is a corrected observationn”
fi