echo "<span foreground=\"green\"><big><i>[`date +%m/%d/%Y`]</i></big></span>";
-t 1 try just one time and abort if unsuccessful -T 10 abort operation if not completed within 10 seconds -q be quiet and do not output any warning/error/operation message -O - print fetched page to standard output `date +%Y%m%d` will be substituted at runtime with the current date in the format <yyyymmdd> to identify the correct webpage to be fetched
wget -t 1 -T 10 -q -O - http://m.mlb.com/scores/`date +%Y%m%d`/
BEGIN { t="NYY"; # Favourite Team!!! m=0; } /<td>.+<\/td>/ { # We find every line of the table which displays results s=gensub(/<[^>]*>/,"","g"); # We remove every simple HTML tag from # out input s=gensub(/[\t ]+/," ","g",s); # and replace every multiple instances # of TABs or SPACEs with just one SPACE split(s,a); # We create an array of blank delimited fields # representing our teams name, score, "vs." string, # situation "Final", "Top 5" ... if(a[1]!=t && a[3]!=t && a[4]!=t) { # Test if our favourite team print s; # just print with no special # Pango tag if other teams next; # and go parse next line } m=1; # Found favourite team... set flag accordingly # Print our fav Team's match with Pango tags for cyan color, # bold & big size font print "<span foreground=\"cyan\"><b><big>" s "</big></b></span>"; if(a[2]=="vs.") { # if second field is string "vs." and not a score # this means game has not started yet ex=1; # We will exit with just a neutral exit status next; # and go parse next line } if((a[4]==t&&a[5]>a[2])||(a[1]==t&&a[2]>a[5])) { # Checks is our fav # Team's winning!!! ex=0; # Yes ... prepare exit with big smiley face exit status! next; # and go parse next matches } if(a[5]==a[2]) { # Is this a still tie game?? ex=1; # Yes ... We will exit with just a neutral exit status next; # and go parse next matches } else { # We have lost ... SAD news!!! ex=2; # Prepare mourning exit status next; # sadly process other teams } } END { # these will be the very last statements performed if(m==0) { # Have we found our fav team's match print "No\nMatch!\n"; # No ... just output a No Match at the # end of the list exit 1; # and exit with neutral exit status } else exit ex; # we now return to beecon with defined exit status }