Solved

appending date to file created in Unix shell Script

Posted on 2008-10-14
9
1,452 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 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
@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
 
LVL 48

Expert Comment

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

Open in new window

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to take different types of Oracle backups using RMAN.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now