macで特定期間ループするshスクリプトが書きたい
覚えておける自信がないのでメモ
#!/bin/sh startdate="2011-04-30" stopdate="2011-05-03" cnt=0 while [ 1 ] ;do nowdate=`date -v+${cnt}d -j -f "%Y-%m-%d" "${startdate}" +"%Y-%m-%d"` echo "shori" ${nowdate} if [ ${nowdate} = ${stopdate} ] ; then break fi let cnt=$cnt+1 done
実行結果
% sh date_loop.sh shori 2011-04-30 shori 2011-05-01 shori 2011-05-02 shori 2011-05-03
実際使う時は処理をコマンドに置き換えるといいよ!
BSD系のdateのusage: http://www.jp.freebsd.org/cgi/mroff.cgi?sect=1&cmd=&lc=1&subdir=man&dir=jpman-6.0.0%2Fman&man=date#toc