I have a following simple extract from my script which is strangely stuck up for a particular inputs.
echo -e "Enter the Day of the Month : \c " read input_day printf -v input_day '%02d' "$input_day"
This makes sure that if the user inputs a single digit number e.g. 2 then it converts it to 02. Which is my first requirement. This also works if one enters 2 digits number as 02. Then it retains it as 02. This also works for a 2 digit number as 12. But strangely it fails to accept the digit 08 and 09? This is the error it gives when one enters 08 or 09.
Enter the Day of the Month : 08 2: line 20: printf: 08: invalid number
Why is it so? I tried to read printf help page and it shows that "d" stands for Signed decimal integer. So it should accept the digits 8 and 9. Or am I missing something? My requirement is that user should be able to enter the day of the month as single digit "8" as well as double digit "08".