1 #!/usr/local/plan9/bin/rc
3 path=($path $PLAN9/bin)
6 echo 'usage: yesterday [-cd] [-[[yy]yy]mm]dd] [-n daysago] file ...' >[1=2]
16 if(! cmp -s $1 $2) Xcp $1 $2
28 year=`{date|sed 's/.* //'}
31 while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){
50 days=`{echo $1 | sed 's/^-.//'}
51 last=`{date -r `{perl -e 'print time() - '$days'*60*60*24'} |
52 9 sed -e 's%... (...) (..) ..:..:.. ... (....)%\3/\1\2%' -e 'y/ /0/' -e $smon}
55 mon=`{date|9 sed 's/^....(...).*/\1/' -e $smon}
56 last=$year/$mon ^`{echo $1|sed 's/^-/0/'}
59 mon=`{date|9 sed 's/^....(...).*/\1/' -e $smon}
60 last=$year/$mon ^`{echo $1|9 sed 's/^-//'}
62 case -[0-9][0-9][0-9][0-9]
63 last=$year/ ^ `{echo $1|9 sed 's/^-//'}
65 case -[0-9][0-9][0-9][0-9][0-9][0-9]
66 last=`{echo $year|9 sed 's/..$//'} ^ `{echo $1|9 sed 's/^-(..)/\1\//'}
68 case -[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
69 last=`{echo $1|9 sed 's/^-(....)/\1\//'}
75 if(! ~ $#* 0 && ~ $1 --)
83 echo 'yesterday: can''t find directory' >[1=2]
92 if(! test -d /dump/$h){
93 echo 'no dumps on '^`{hostname} >[1=2]
102 xpath=`{9 cleanname -d `{pwd} $i}
105 xlast=`{9 ls -t $xdump/$year|sed 1q}
108 $copy $xlast^$dumppath $xpath