Quick Bash Scripting question
I am trying to create a script that makes a directory for the day prior to today.
here is the code so far.
#sets up variables
day=$((`date +'%d'`- 1))
It works fine, but the problem is that the date needs a zero in front of it, so that all directories have the same amount of characters. ie todays date would be 05.05.05.
I can get a zero in front of the 6 in 2 ways, but once the day is above 11 it gives me 3 characters. Basically i want the variable to have a length of 2 characters.
Right now i can get 05.5.05 as is, but i need it to be 05.05.05. I also need the 05.10.05 to stay like that and not have more than 2 characters in each field. I know it may not make sense, but I am unable to find how to make a variable have to return 2 characters only.
Last edited by Kedelfor; 05-06-2005 at 07:07 AM.