appending date to file created in Unix shell Script

I want to append the date to a file created in a Unix Shell Script

example  release.dmp101408

 created from an oracle export
TDS-ITAsked:
Who is Participating?
 
woolmilkporcCommented:
release.dmp$(date +"%m%d%y")
e.g. [script] > release.dmp$(date +"%m%d%y")
For oracle, you could create/modify the parfile by a script which inserts the above after FILE=

0
 
omarfaridCommented:
you can set filename by

myfile=release.dmp`date +%m%d%y`

then use $myfile as the file name for the export dump
0
 
woolmilkporcCommented:
@omarfarid: Are you sure that FILE=$myfile in an Oracle parfile will work?
What I meant to suggest is to let a shell expand  'release.dmp$(date +"%m%d%y")' and insert the resulting string  behind FILE=  in the parfile.
And, as one can see, I don't like those *gly backticks ...
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
TintinCommented:
Simply do
date "release.dmp+%m%d%y" >>/your/export/file

Open in new window

0
 
omarfaridCommented:
Hi woolmilkporc,

Thank you for your comment :)

If you work in the unix world then you should expect things like backticks or inverted commas and more. This is what the system can do

If you want to export data from oracle database you may use oracle tools and pass arguments to it with the command line
0
 
woolmilkporcCommented:
Hi omarfarid,
I expect them (since more than 15 years in the unix world), but don't love them :-)
But back to topic:
command line is surely no problem, but how about the parfile, and what happens if you let exp prompt you for values?
0
 
omarfaridCommented:
If it comes to manual entry then it can be entered by hand.

Regarding the parfile, I am not sure since I am not in touch with oracle for long time
0
 
TintinCommented:
The question is a little unclear.  I interpreted the question as appending a date to a file, whereas others have interpreted it as appending a date to a filename.

We need some clarification from TDS-IT
0
 
woolmilkporcCommented:
Hi,
if you are not familiar with Oracle exp using a PARFILE,
here is an example script. It contains only a few parameters for exp.
wmp

#!/bin/ksh
#   --  some variables for exp parfile --  set as required -- #
USERID=[name/pass]
OWNER=[schema]
ROWS=[Y/N]
GRANTS=[Y/N]
INDEXES=[Y/N]
CONSISTENT=[Y/N]
CONSTRAINTS=[Y/N]
FILE=release.dmp$(date +"%m%d%y")  #  <-- here it is!  #
 
#  --  the parfile itself  --  #
TEMP_PARFILE=/tmp/parfile.$$
 
#  --  create parfile  --  #
echo USERID=$USERID > $TEMP_PARFILE
echo OWNER=$OWNER >> $TEMP_PARFILE
echo ROWS=$ROWS >> $TEMP_PARFILE
echo GRANTS=$GRANTS >> $TEMP_PARFILE
echo INDEXES=$INDEXES >> $TEMP_PARFILE
echo CONSISTENT=$CONSISTENT >> $TEMP_PARFILE
echo CONSTRAINTS=$CONSTRAINTS >> $TEMP_PARFILE
echo FILE=$FILE >> $TEMP_PARFILE
 
#  --  Run exp  --  #
exp PARFILE=$TEMP_PARFILE
 
# Insert your checks etc. here  #
 
rm $TEMP_PARFILE
 
exit

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.