Solved

appending date to file created in Unix shell Script

Posted on 2008-10-14
9
1,453 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
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
 
LVL 48

Expert Comment

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

Open in new window

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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 …
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 information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

895 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

17 Experts available now in Live!

Get 1:1 Help Now