Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace a text like ${ORACLE_HOME} in a string by the real value of the variable itself ?

 
Highlighted
Frequent Advisor

How to replace a text like ${ORACLE_HOME} in a string by the real value of the variable itself ?

Hi,

 

How to replace a text like ${ORACLE_HOME} by the real value of the variable itself ?

Here is an example:

PRM_PARMS=BLKSIZE='1048576,SBT_LIBRARY=${ORACLE_HOME}/lib/libddobk.so,ENV=(STORAGE_UNIT=oramount,BACKUP_HOST=server1,ORACLE_HOME=${ORACLE_HOME})'

ORACLE_HOME=/u01/test

I tried something like this:

 

echo $PRM_PARMS | sed 's/'/${ORACLE_HOME}'/${ORACLE_HOME}/g'

 

But without success.

 

Do you have any idea of the sed command I should write ?

 

Thanks a lot in advance,

Kind regards,

Den.

2 REPLIES 2
Highlighted
Honored Contributor

Re: How to replace a text like ${ORACLE_HOME} in a string by the real value of the variable itself ?

Not sure what you need, but simply tracing the script will show the value for each variable.
Insert the command: set -x into the script
or run the script with -x as in:   ksh -x myscript

 



Bill Hassell, sysadmin
Highlighted
Frequent Advisor

Re: How to replace a text like ${ORACLE_HOME} in a string by the real value of the variable itself ?

I finally found a solution .../

 

PRM_PARMS=$(echo $PRM_PARMS | sed "s|\${ORACLE_HOME}|${ORACLE_HOME}|g")

 

 

thanks.