Cadillac84
08-26-2002, 01:33 AM
I am logging events continuously and want to start a new log each day using the date as the file name.
At a shell prompt, I can obtain the desired filename thusly:
DATE='date +%y%m%dxyz.log'
$DATE will print 020826xvz.log
That ("020826xyz.log") is what I'd like my filename to be.
If I set the string DATE explicitly such as:
DATE='020826xyz.log'
then I can do things like
ls -l > $DATE
and I get a file with the desired name.
However, if I try to set the date using the 'date' function, then when I try to create the file, I get an error message:
"bash: $DATE: ambiguous redirect
The end result desired is to log activity for a day saving the results to a file named for that date. At the end of the day, I would stop logging, determine the new date and begin a new log using the then-current date as the file name.
Can someone explain to me where I have wandered off the path?
Thanks in advance.
Chuck Moore
CNMoore@Knology.net
At a shell prompt, I can obtain the desired filename thusly:
DATE='date +%y%m%dxyz.log'
$DATE will print 020826xvz.log
That ("020826xyz.log") is what I'd like my filename to be.
If I set the string DATE explicitly such as:
DATE='020826xyz.log'
then I can do things like
ls -l > $DATE
and I get a file with the desired name.
However, if I try to set the date using the 'date' function, then when I try to create the file, I get an error message:
"bash: $DATE: ambiguous redirect
The end result desired is to log activity for a day saving the results to a file named for that date. At the end of the day, I would stop logging, determine the new date and begin a new log using the then-current date as the file name.
Can someone explain to me where I have wandered off the path?
Thanks in advance.
Chuck Moore
CNMoore@Knology.net