Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

appending date to file created in Unix shell Script

Posted on 2008-10-14
9
Medium Priority
?
1,460 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to recover a database from a user managed backup
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

715 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