1 #!/usr/local/plan9/bin/rc
20 echo 'usage: yesterday [-cd] [-[[yy]yy]mm]dd] [-n daysago] file ...' >[1=2]
30 if(! cmp -s $1 $2) Xcp $1 $2
42 year=`{date|sed 's/.* //'}
45 while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){
64 days=`{echo $1 | sed 's/^-.//'}
65 last=`{date `{hoc -e `{date -n} ^ '-'$days'*60*60*24'} | \
66 sed -e 's%... (...) (..) ..:..:.. ... (....)%\3/\1\2%' -e 'y/ /0/' -e $smon}
69 mon=`{date|9 sed 's/^....(...).*/\1/' -e $smon}
70 last=$year/$mon ^`{echo $1|sed 's/^-/0/'}
73 mon=`{date|9 sed 's/^....(...).*/\1/' -e $smon}
74 last=$year/$mon ^`{echo $1|9 sed 's/^-//'}
76 case -[0-9][0-9][0-9][0-9]
77 last=$year/ ^ `{echo $1|9 sed 's/^-//'}
79 case -[0-9][0-9][0-9][0-9][0-9][0-9]
80 last=`{echo $year|9 sed 's/..$//'} ^ `{echo $1|9 sed 's/^-(..)/\1\//'}
82 case -[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
83 last=`{echo $1|9 sed 's/^-(....)/\1\//'}
89 if(! ~ $#* 0 && ~ $1 --)
97 echo 'yesterday: can''t find directory' >[1=2]
106 if(! test -d /dump/$h){
107 echo 'no dumps on '^`{hostname} >[1=2]
116 xpath=`{9 cleanname -d `{pwd} $i}
119 xlast=`{9 ls -t $xdump/$year|sed 1q}
122 $copy $xlast^$dumppath $xpath