Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- declare -i Result_M
- declare -i Resilt_S
- declare -i Resilt_H
- start=`date | cut -d " " -f 6`
- start_H=`echo $start |cut -d ":" -f 1`
- start_M=`echo $start |cut -d ":" -f 2`
- start_S=`echo $start |cut -d ":" -f 3`
- echo "Prease press the Enter Key if you want to stop."
- read PUSH_KEY
- #if [ "$PUSH_KEY" = "" ]; then
- # echo "Stop"
- #fi
- End=`date |cut -d " " -f 6`
- End_H=`echo $End | cut -d ":" -f 1`
- End_M=`echo $End | cut -d ":" -f 2`
- End_S=`echo $End | cut -d ":" -f 3`
- Result_H=$(($End_H - $start_H))
- Result_M=$(($End_M - $start_M))
- Result_S=$(($End_S - $start_S))
- if [ $Result_S -lt 0 ]; then
- Result_H=`expr 24 + $Result_S`
- fi
- if [ $Result_M -lt 0 ]; then
- Result_M=$((60 + $Result_M))
- Result_H=`expr Result_H - 1`
- fi
- if [ $Result_S -lt 0 ]; then
- Result_S=`expr 60 + $Result_S`
- Result_M=`expr $Result_M - 1`
- fi
- echo "$Result_H 時間 $Result_M 分 $Result_S 秒"
- exit 0
Add Comment
Please, Sign In to add comment