![]() |
|
|
|
|
|||||||
| 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 |
| How to edit a txt file ? | RRVARMA | Shell Programming and Scripting | 4 | 05-30-2008 05:40 AM |
| edit a file using ksh | meghana | Shell Programming and Scripting | 3 | 04-16-2008 08:04 AM |
| How to edit env file | duke0001 | UNIX for Advanced & Expert Users | 3 | 02-16-2007 08:43 AM |
| file edit help | sentak | Shell Programming and Scripting | 10 | 11-14-2006 05:20 AM |
| Edit an ISO / dd file? | WIntellect | Filesystems, Disks and Memory | 4 | 11-20-2002 02:21 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Edit value in File
I have a file oratab with entry like this
SCADAG:/esitst1/oracle/product/9.2.0.8:Y I am trying to discover a way to change the 9.2.0.8 part of this to something like 10.2.0.4 as part of an upgrade script. I have tried cat /etc/oratab >>/tmp/oratab ORACLE_HOME=/esitst1/oracle/product/9.2.0.8 export ORACLE_HOME NEW_HOME=/esitst1/oracle/product/10.2.0.4 export New_HOME sed -e "s/${ORACLE_SID}:${ORACLE_HOME}/${ORACLE_SID}:${NEW_HOME}/g" /tmp/oratab >/etc/oratab If I read it correctly, it appears not to like the forward slashes. Any suggestions as how to do this would be greatly appreciated. I may be even going down the wrong road here. Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
sed allows alternative separators for precisely this reason.
Code:
sed -e "s%${ORACLE_SID}:${ORACLE_HOME}%${ORACLE_SID}:${NEW_HOME}%g
I have been known to write sed scripts which write sed scripts with all the special characters in the input backslashed, but there are obviously more elegant solutions. (Perl comes to mind, and should be easy to get started with if you know sed.) |
|||
| Google The UNIX and Linux Forums |