좀 지저분하고 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"