?
Solved

appending date to file created in Unix shell Script

Posted on 2008-10-14
9
Medium Priority
?
1,462 Views
Last Modified: 2013-12-21
I want to append the date to a file created in a Unix Shell Script

example  release.dmp101408

 created from an oracle export
0
Comment
Question by:TDS-IT
  • 4
  • 3
  • 2
9 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 22714129
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 22714241
you can set filename by

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

then use $myfile as the file name for the export dump
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22714596
@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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 48

Expert Comment

by:Tintin
ID: 22714704
Simply do
date "release.dmp+%m%d%y" >>/your/export/file

Open in new window

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22714743
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
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22714910
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 22715021
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
 
LVL 48

Expert Comment

by:Tintin
ID: 22715478
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
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22765224
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question