Hi Chris,<br> I believe you've already seen two solutions, but I'd still like to offer my preferred alternative...<br><br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">#!/bin/bash
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">## ^ ksh isn't available in Ubuntu by default :)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">YEAR=`date +%Y`</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">MONTH=`date +%m`</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">DAY=$(( `date +%d` )) - 1</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
# Let the shell do the basic math instead of calling an external program</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
if [ $DAY -eq 0 ]; then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> MONTH=$(( MONTH - 1 ))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
[ $MONTH -eq 0 ] && $MONTH = 12</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> DAY=`cal $MONTH | tr -d "\b" | fmt -1 | tail -1`</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">fi</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># This shortcut to an if/then statement is just as effective, but nicer to read
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># It's the same as:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
# if [ $DAY -lt 10 ]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
# DAY="0$DAY"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># fi</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
[ $DAY -lt 10 ] && DAY="0$DAY"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#[ $MONTH -lt 10 ] && MONTH="0$MONTH"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">echo "Yesterday was $MONTH $DAY $YEAR</span><br></div><br><br><br><div><span class="gmail_quote">On 5/15/07, <b class="gmail_sendername">
Nils Kassube</b> <<a href="mailto:kassube@gmx.net">kassube@gmx.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><a href="mailto:chrisl@xp.etowns.net">
chrisl@xp.etowns.net</a> wrote:<br>> I have the following script:<br>><br>...<br></blockquote><div> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
><br>> The value DAY6 would be 13 if run today. If it was run on the 10th it<br>> would be 9.<br>><br>> I need to have DAY6 displayed as 09 and not just 9, is this possible?</blockquote><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
How about this one? </blockquote><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">echo "1 day ago was: $(date -d yesterday '+%m %d %Y')"
</blockquote><div><br>Thanks, Nils.. I didn't know date had that argument :) <br></div></div><br><br>-- Vince<br>