HP-UX 에서 날짜 가져오기, for문, while문
2010. 12. 7. 10:44ㆍ99. 정리전 - IT/13. Unix 얇팍지식
하루전 날짜 가져오기
MON=`date +%m`
DAY=`date +%d`
YEAR=`date +%Y`
if [[ "$MON" = "01" ]] && [[ "$DAY" = "01" ]] then
MON=12
(( YEAR=$YEAR - 1 ))
DAY=`cal $MON $YEAR |tail +3 |wc -w`
elif [[ "DAY" -eq 01 ]] && [[ "$MON" -ne 01 ]] then
(( MON=$MON - 1 ))
DAY=`cal $MON $YEAR |tail +3 |wc -w`
else
(( DAY=$DAY - 1 ))
fi
if [[ $DAY -lt 10 ]] then
DAY=0$DAY
fi
if [[ $MON -lt 10 ]] then
MON=0$MON
fi
WORK_DATE=$YEAR$MON$DAY
DAY=`date +%d`
YEAR=`date +%Y`
if [[ "$MON" = "01" ]] && [[ "$DAY" = "01" ]] then
MON=12
(( YEAR=$YEAR - 1 ))
DAY=`cal $MON $YEAR |tail +3 |wc -w`
elif [[ "DAY" -eq 01 ]] && [[ "$MON" -ne 01 ]] then
(( MON=$MON - 1 ))
DAY=`cal $MON $YEAR |tail +3 |wc -w`
else
(( DAY=$DAY - 1 ))
fi
if [[ $DAY -lt 10 ]] then
DAY=0$DAY
fi
if [[ $MON -lt 10 ]] then
MON=0$MON
fi
WORK_DATE=$YEAR$MON$DAY
1부터 10까지 출력
#!/bin/sh
i=1
while [ $i -lt 10 ]
do
i=`expr $i + 1`
echo $i
done
i=1
while [ $i -lt 10 ]
do
i=`expr $i + 1`
echo $i
done