Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Putting the current date in a filename using a script 1

Status
Not open for further replies.

scoobs

Instructor
Aug 5, 2002
17
US
I am creating a report and outputing to a filename. I can't get the current date on the filename because of the report writer limitations. How can I get the current date on the file?
 
you're question is very broad... You state it's a script... What kind of script, perl, bash, python, etc... why not just enter a

echo `date`

somewhere in the script? Or if its something precompiled, you could still echo `date` >> output. what kind of output is this report, xls, db, txt, pdf, could you be a bit more specific, also what kind of script?

sil
 
Could you accept the limitations and simply set up a cron job to rename the file produced each day?
 
if you buld a script for that:

Code:
#!/usr/bin/ksh

REPORTFILE=`date '+%m%d%y'`

./reportscriptname > $REPORTFILE

___________________________________
[morse]--... ...--[/morse], Eric.
 
The script is written in Unix. The script calls another script to generate thne file in a report writer. I have the report writer generate part of the name because of it's limitations. How do I re-name the file including todays date?
 
The script is written in Unix
Unix is an Operating System, not a scripting language.
Ask your sysadmin which shell is used on your location for this script.
You may try something like this:
mv reportname newname$(date +%Y-%m-%d_%H_%M).rpt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top