Sorry for the duplicate thread this one is similar to the one in
https://www.unix.com/shell-programmin...#post302255121
Since there were no responses on the parent thread since it got resolved partially i thought to open the new thread for the remaining issue
I am writing a shell program that executes a lot of Oracle SQL Files on different databases based on the enviroment setting value. I am trying to design a parameter file where i can store the environment values for all the databases in the below format
Environment File
File Name oraenv
# /* DB1 */
ORACLE_SID=DB1
ORACLE_BASE=
ORACLE_HOME=
PATH=
LD_LIBRARY_PATH=
.
.
Other Parameters
# /* End */
# /* DB2 */
ORACLE_SID=DB2
ORACLE_BASE=
ORACLE_HOME=
PATH=
LD_LIBRARY_PATH=
.
.
Other Parameters
# /* End */
# /* DB3 */
ORACLE_SID=DB3
ORACLE_BASE=
ORACLE_HOME=
PATH=
LD_LIBRARY_PATH=
.
.
Other Parameters
# /* End */
Master Script <-- Main Program that uses these parameters
File Name actions.sh
When the script is executed as ./actions,sh DB1 i want this to read all the parameters related to DB1 from the oraenv written between the pattern below
# /* DB1 */
.
...
..
# /* End */
create "export ORACLE_SID .." etc...
Solution
DB=DB1
for LINE in `sed -n '/ '${DB}' /,/ End /p' oraenv| grep -v ^#`; do
export "${LINE}"
done
The problem with the above code is some of the parameters in the oraenv file have $.. Like as below
# /* DB1 */
ORACLE_HOME=/temp
OH=$ORACLE_HOME
# /* End */
Expected result is
ORACLE_HOME=/temp
OH=/temp
Actual results
ORACLE_HOME=/temp
OH=$ORACLE_HOME
I have been struggling to resolve this issue for 4 hrs now... Any quick help is very appreciated.