Please help on this


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Please help on this
# 1  
Old 06-20-2007
Please help on this

iam newbie to unix please help on this issue


exp username/password@databasename file=PMGR_AMPD_ 06132007.dmp statistics=none log=exp_PMGR_AMPD_ 06132007.log

i have the script file with above string, but in that string i want replace the Date with sysdate in same format(mmddyyyy) Regularly
how can i change ,

is there any commands in unix for purpose of find & replace from the scriptfile.

Please help on this
# 2  
Old 06-20-2007
Code:
dt=$(date +%m%d%Y)
sed "s/[0-9]\{8\}/$dt/g" file >tmp
mv tmp file

# 3  
Old 06-20-2007
There is no need for the "g" at the end of the "s" command.
Its presence means to change all occurrences in each line
and in this specific case, there is only one occurrence.
# 4  
Old 07-08-2007
The correct solution however is to rewrite the script to parametrize the, uh, parameter correctly.

#!/bin/sh

param=$1

exp username/password@databasename file=PMGR_AMPD_ $param.dmp statistics=none log=exp_PMGR_AMPD_ $param.log

Then you'd execute that with the required date, i.e. "script 06132007" to run it with param set to 06132007. Or if the parameter can be derived from the date when the script is run or some such then by all means do that automatically, i.e. param=$(date +%d%m%Y)

Last edited by era; 07-08-2007 at 04:08 PM.. Reason: Spurious newline
era
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question