on a unix server I have a mapping file which holds a list mountpoints of all databases and their mountpoints. tab delimited or colon deliminted..I needed to copy the datafiles from the pristine mountpoints to test's mountpoints in this case. I needed to do this by passing sid name using $SID. How can I perform that?
ex.
cat mapfile.lst
test /u01:/u02:/u03:/u04
dev /u05:/u06:/u07:/u08
Pristine mountpoints
/u01p:/u02p:/u03p:/u04p
thanks
I came up with this but its not working..I somehow need to do the following.
a. grep for test then move onto building the cp query. the cp query should look like..
cp -rp /u01_p /pristine u01/oradata/test
cp -rp /u02_p /pristine u02/oradata/test
for i in `cat dbmap|awk '{for (i=2; i<=NF; ++i) print $i}'`;
do
cp -p -r ${i} $i
done
dbmap is the mapfile.lst file which holds the following data.
test /u01:/u02:/u03:/u04
dev /u05:/u06:/u07:/u08
I dont now how to derive the '/u01_p' mountpoint. There are 8 mountpoints with that for source and target. the source is always static but the target is could be /u01..u08 or /u11..u18 or /u21..u28
'/u01_p'
'/u02_p'
...
'/u08_p'
the cp example i gave "cp -rp /u01_p /pristine u01/oradata/test" is what i need to derive from the routine...
ex.. the desired output should be...
definately. some questions. How are you catting the mapfile in the code?
the output you got was the following
code:
cp -rp /u01_p /pristine /u01/oradata/test
cp -rp /u02_p /pristine /u02/oradata/test
cp -rp /u03_p /pristine /u03/oradata/test
cp -rp /u04_p /pristine /u04/oradata/test
cp -rp /u05_p /pristine /u05/oradata/dev
cp -rp /u06_p /pristine /u06/oradata/dev
cp -rp /u07_p /pristine /u07/oradata/dev
cp -rp /u08_p /pristine /u08/oradata/dev
code:
but what if I just want to build a copy statement for test and omit dev? I somehome wanted to incorporate $SID value which should equal to test.
Thanks..i tried testing the code you gave me...but the output was different. What am I doing wrong? I am not good with awk/shell programming. the other thing is that the output should be like the following..
cp -rp /u09_p/pristine /u09/oradata/test
cp -rp /u10_p/pristine /u10/oradata/test <---/u10 is not being grabbed
not
cp -rp /u09_p/pristine /u09/oradata/test
cp -rp /u01_p/pristine /u01/oradata/dev