change date format - 2009-10-30 -> today

Hello, new to this forum, I'm running Ubuntu 9.10 i386. I've search and found some relevant info on how to do this but I haven't been able to figure it all out. I'm trying to output my mythtv pvr's upcoming schedule but I'd like to change the dates from 2009-10-30 -> today, 2009-10-31 -> tomorrow and 2009-11-01 -> sunday. Having todays date come up as 'today' isn't too important, resorting to day of the week is better than nothing.

myth_upcoming_recordings.pl --plain_text --text_format '%Y-%m-%d - %h:%i %A - %T - %S (%cN)\n' --heading ""
2009-10-30 - 04:00 PM - Ghost Hunters - Nightmare Noises (OLCC)
2009-10-30 - 05:30 PM - The Simpsons - Treehouse of Horror XI (KCPQ)
2009-10-30 - 06:00 PM - The Simpsons - Treehouse of Horror XII (KCPQ)
2009-10-30 - 09:00 PM - The Simpsons - Treehouse of Horror XIX (COMEDCP)
2009-10-31 - 12:00 AM - Project Runway - A Fashionable New Beginning (SLICE)

the closest I've gotten is pretty bad

TEXT=`myth_upcoming_recordings.pl --plain_text --text_format '%Y-%m-%d - %h:%i %A - %T - %S (%cN)\n' --heading ""`
DATE=`echo "$TEXT"|awk -F'% ' {'print $1'}`
SHOW=`echo "$TEXT"|awk -F'% ' {'print $2 $3 $4 $5 $6'}`
DAY=`date -d $DATE +%a`
awk -v DAY="$DAY" SHOW="$SHOW"'{print DAY SHOW}'

there is a lot of configuration with the myth_upcoming_recordings.pl script if it makes it easier

--text_format

    %T   = Title (show name)
    %S   = Subtitle (episode name)
    %R   = Description
    %C   = Category
    %U   = RecGroup
    %hn  = Hostname of the machine where the file resides
    %c   = Channel:  MythTV chanid
    %cn  = Channel:  channum
    %cc  = Channel:  callsign
    %cN  = Channel:  channel name
    %y   = Recording start time:  year, 2 digits
    %Y   = Recording start time:  year, 4 digits
    %n   = Recording start time:  month
    %m   = Recording start time:  month, leading zero
    %j   = Recording start time:  day of month
    %d   = Recording start time:  day of month, leading zero
    %g   = Recording start time:  12-hour hour
    %G   = Recording start time:  24-hour hour
    %h   = Recording start time:  12-hour hour, with leading zero
    %H   = Recording start time:  24-hour hour, with leading zero
    %i   = Recording start time:  minutes
    %s   = Recording start time:  seconds
    %a   = Recording start time:  am/pm
    %A   = Recording start time:  AM/PM
    %ey  = Recording end time:  year, 2 digits
    %eY  = Recording end time:  year, 4 digits
    %en  = Recording end time:  month
    %em  = Recording end time:  month, leading zero
    %ej  = Recording end time:  day of month
    %ed  = Recording end time:  day of month, leading zero
    %eg  = Recording end time:  12-hour hour
    %eG  = Recording end time:  24-hour hour
    %eh  = Recording end time:  12-hour hour, with leading zero
    %eH  = Recording end time:  24-hour hour, with leading zero
    %ei  = Recording end time:  minutes
    %es  = Recording end time:  seconds
    %ea  = Recording end time:  am/pm
    %eA  = Recording end time:  AM/PM
    %py  = Program start time:  year, 2 digits
    %pY  = Program start time:  year, 4 digits
    %pn  = Program start time:  month
    %pm  = Program start time:  month, leading zero
    %pj  = Program start time:  day of month
    %pd  = Program start time:  day of month, leading zero
    %pg  = Program start time:  12-hour hour
    %pG  = Program start time:  24-hour hour
    %ph  = Program start time:  12-hour hour, with leading zero
    %pH  = Program start time:  24-hour hour, with leading zero
    %pi  = Program start time:  minutes
    %ps  = Program start time:  seconds
    %pa  = Program start time:  am/pm
    %pA  = Program start time:  AM/PM
    %pey = Program end time:  year, 2 digits
    %peY = Program end time:  year, 4 digits
    %pen = Program end time:  month
    %pem = Program end time:  month, leading zero
    %pej = Program end time:  day of month
    %ped = Program end time:  day of month, leading zero
    %peg = Program end time:  12-hour hour
    %peG = Program end time:  24-hour hour
    %peh = Program end time:  12-hour hour, with leading zero
    %peH = Program end time:  24-hour hour, with leading zero
    %pei = Program end time:  minutes
    %pes = Program end time:  seconds
    %pea = Program end time:  am/pm
    %peA = Program end time:  AM/PM
    %oy  = Original Airdate:  year, 2 digits
    %oY  = Original Airdate:  year, 4 digits
    %on  = Original Airdate:  month
    %om  = Original Airdate:  month, leading zero
    %oj  = Original Airdate:  day of month
    %od  = Original Airdate:  day of month, leading zero
    %%   = a literal % character

Hi mrplow, try this :

for i in Today Tomorrow Monday Thursday Wednesday Thursday Friday Saturday Sunday; do
  sedstr="${sedstr}s/$(date -d $i +%Y-%m-%d)/$i/;"
done
myth_upcoming_recordings.pl --plain_text --text_format '%Y-%m-%d - %h:%i %A - %T - %S (%cN)\n' --heading "" |
while read date rest; do
  printf "%-10s %s\n" $(echo $date |sed "$sedstr") "$rest"
done

(not surprised you like the simpsons, mr. plow :wink: )

Geez, I spent my last two lunch hours trying to figure it out. Thanks Scrutinizer. Only problem is the tree spaces after the day, I'd like to squeeze it into the smallest space I can.

Today      - 09:00 PM - The Simpsons - Treehouse of Horror XIX (COMEDCP)
Tomorrow   - 12:00 AM - Project Runway - A Fashionable New Beginning (SLICE)
Tomorrow   - 12:00 AM - The King of Queens - Court Date (TROPP)
Tomorrow   - 12:30 AM - The King of Queens - White Collar (TROPP)
Tomorrow   - 01:00 PM - Models of the Runway - A Fresh Start (SLICE)

ignore the runway shows, thats for the WAF

The width of the first column is controlled by %-10s . I used 10 so the output would be aligned for the other possible outcomes, e.g.

Today      - 04:00 PM - Ghost Hunters - Nightmare Noises (OLCC)
Tomorrow   - 05:30 PM - The Simpsons - Treehouse of Horror XI (KCPQ)
Monday     - 06:00 PM - The Simpsons - Treehouse of Horror XII (KCPQ)
Wednesday  - 09:00 PM - The Simpsons - Treehouse of Horror XIX (COMEDCP)
2009-11-08 - 12:00 AM - Project Runway - A Fashionable New Beginning (SLICE)

You can play with that number and see what you like best, e.g. %-8s , %10s, %s etc...

cool thats perfect then, thanks