![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing a variable inside a variable to a function | KingVikram | UNIX for Dummies Questions & Answers | 2 | 01-14-2008 05:28 PM |
| How to replace variable inside the variable | mani_um | Shell Programming and Scripting | 31 | 08-09-2007 07:56 PM |
| Replace variable with a user defined variable | ce124 | Shell Programming and Scripting | 1 | 04-15-2007 11:56 AM |
| Export command giving Variable Name vs the Value set for the Variable | ParNone | UNIX for Dummies Questions & Answers | 2 | 04-03-2006 08:43 AM |
| ksh: A part of variable A's name is inside of variable B, how to update A? | pa3be | Shell Programming and Scripting | 4 | 03-30-2005 08:29 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
sed (variable)
HOw can I use any variable in sed command.
For example I am using 'sed -e 's/?/$ORACLE_HOME/g' $file_name Here it replaces ? with $ORACLE_HOME. Instead of it I need actual value of $ORACLE_HOME. How can I do that? Please advice. Thanks in advance. Malay |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
quote them to substitute
sed -e 's/abc/'$ORACLE_HOME'/g' <filename> |
|
#3
|
|||
|
|||
|
==> sed -e 's/?/'$ORACLE_HOME'/g' dest.log
sed: command garbled: s/?//diqr001/opt/tools/oracle/product/9.2.0/g Not working. Malay |
|
#4
|
|||
|
|||
|
Quote:
when substituting with sed they have to be disabled with a "\" following is just an example echo "abc" | sed -e 's/abc/\/diqr001\/opt\/tools\/oracle\/product\/9.2.0/' change ur script accordingly |
|
#5
|
||||
|
||||
|
Quote:
Code:
sed -e "s/abc/$ORACLE_HOME/g" <filename> |
|
#6
|
|||
|
|||
|
But how can I replace '/' in $ORACLE_HOME with '\/'?
Malay |
|
#7
|
||||
|
||||
|
Quote:
Code:
sed -e "s/?/$ORACLE_HOME/g" $file_name |
||||
| Google The UNIX and Linux Forums |