Help - Search - Members - Calendar
Full Version: Automatic File Naming Question
Linuxhelp > Support > Technical Support
Robert83
I use bdc with crontab to make it update at 02:00 and scan for viruses at 04:00 every day, I give the bdc the option to output the report in /viruslog/report.

Now, the question is , is there a character of some sort [variable or something], that I can use after report so that it will make a report2004Feb20 ...report2004Feb21 etc....


Sincerely
Robert B
hughesjr
I don't know what program you are using, but in a bash script you can create a variable with the date and format it however you want ... here is a simple script:


CODE
#!/bin/bash

today=`date +%G%b%d`

echo $today

today_report="/viruslog/report-"$today

echo $today_report


First thing to note is that the ` character is the key to the left of the number 1 ... not the ' beside the enter key....

In the SH and BASH shells, setting a variable to something inside `` will cause the command to execute and return the results...

In the above script, you can use a # in front of the echo commands to remark them out and use the variables $today and $today_report

If you would like a different format of the date, see man date for all the formats available.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.