Originally Posted by mehreen124
I wanted to subtract $1 and $7 and then multiply with 12. for conversion of years into months.
#converting years into months after subtracting years.
#converting months into days
is this correct?
I simply want to get the difference of the two dates and convert into days.
I know what you are trying to get, and I'm also not going to do your homework for you.
What you should do is put this line in your script so it starts:
The set -x will show you each line of your script as it's being run and with the parameters expanded.
So, if you're running your script with 20 04 1992 - 14 02 2014 That makes your parameters:
$1 = 20
$2 = 04
$3 = 1992
$4 = -
$5 = 14
$6 = 02
$7 = 2014
Your months= line is going to use 20 as $1, and 2014 as $7 then multiplying it by 12.
And then your days line is just going to totally compound your error.
Your calculations are fundamentally wrong, before you even get in to the scripting part of solving this problem.