CnUnix

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ CnUnix ] in KIDS
글 쓴 이(By): sang (Grid)
날 짜 (Date): 2006년 9월 20일 수요일 오후 07시 23분 04초
제 목(Title): Re: [Q] 걸린 시간 초로 바꾸기 (쉘스크립�



좀 지저분하고 bash이긴 하지만-_-; ksh에도 유사한게 있지 않을까하는..
또는 ksh script에서 bash script 불러서 사용하는 방법도.. ㅎㅎ

---
#!/bin/sh

sec=0
mul=1
cnt=1
time=$1

if [ -z $time ]; then
    echo "Usage: $0 [t:][m:][s]."
    exit 1
fi

while [ 1 ]; do
    if [ $cnt -gt 3 ]; then
        echo "Usage: $0 [t:][m:][s]."
        exit 1
    fi

    str=${time##*:}
    sec=$(($sec + $str * $mul))
    time=${time%:*}

    if [ $str == $time ]; then
        break;
    fi

    mul=$(($mul * 60))
    cnt=$(($cnt + 1))
done

echo "seconds = $sec"


[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.