I’m working on this function that basically works on 2 dates.
One is the current date, the other is a 1 month ago date.
Heres the code:
dateTale=$(date -d "$(date) - 1 month" +%Y%m%d)
now=$(date +%Y%m%d)
while ["$dateTale" -lt "$now"]
do
$dateTale=$(date -d "$dateTale + 1 day" +%Y%m%d)
echo "adding"
done
As you can see i’m trying to increase dateTale until it reaches the current date, buit i keep on getting the error message: [20120703: command not found
I tried removing the quotes from within the while statement but still same error message.
But even when resolved, will -lt calculate the actual date value or the numeric one?
Any advice?
Spaces are important when using the
[command:Also, you don’t use the ‘$’ when assigning to variables (unlike perl or php):