Enter number of hours and find days, months and years.
echo -e "Enter Hours: \c"
read hr
echo "hour=$hr"
day=0
mon=0
yr=0
yr=`echo "$hr/365" | bc `
tmp=`echo "$hr%365" | bc`
mon=`echo "$tmp/30" |bc`
day=`echo "$tmp%30" | bc`
echo -e "$hr hours = $yr years and $mon months and $day days"
Output
sh cnthour.sh
Enter Hours: 450
hour=450
450 hours = 1 years and 2 months and 25 days
sh cnthour.sh
Enter Hours: 370
hour=370
370 hours = 1 years and 0 months and 5 days