Created
August 9, 2013 10:29
-
-
Save ftkro/6192676 to your computer and use it in GitHub Desktop.
稼働率計算
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
month=`date +"%m"` | |
function 30days { | |
echo -n "ダウンタイムを入力してください: " | |
read worktime | |
echo "scale=4; ( 43200 - $worktime ) / 43200 * 100" | bc | cut -c 1-5 | |
} | |
function 31days { | |
echo -n "ダウンタイムを入力してください: " | |
read worktime | |
echo "scale=4; ( 44640 - $worktime ) / 44640 * 100" | bc | cut -c 1-5 | |
} | |
while : | |
do | |
case $month in | |
01) 31days | |
break;; | |
02) let Y4=$DATE_YYYY%4 | |
let Y100=$DATE_YYYY%100 | |
let Y400=$DATE_YYYY%400 | |
if [ $Y4 -eq 0 -a! $Y100 -eq 0 -o $Y400 -eq 0] | |
then | |
echo -n "ダウンタイムを入力してください: " | |
read worktime | |
echo "scale=4; ( 41760 - $worktime ) / 41760 * 100" | bc | cut -c 1-5 | |
else | |
echo -n "ダウンタイムを入力してください: " | |
read worktime | |
echo "scale=4; ( 40320 - $worktime ) / 40320 * 100" | bc | cut -c 1-5 | |
fi | |
break;; | |
03) 31days | |
break;; | |
04) 30days | |
break;; | |
05) 31days | |
break;; | |
06) 30days | |
break;; | |
07) 31days | |
break;; | |
08) 31days | |
break;; | |
09) 30days | |
break;; | |
10) 31days | |
break;; | |
11) 30days | |
break;; | |
12) 31days | |
break;; | |
esac | |
echo "申し訳ございませんが、内部エラーが発生しました。" | |
exit 1 | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment