![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to edit a txt file ? | RRVARMA | Shell Programming and Scripting | 4 | 05-30-2008 09:40 AM |
| edit a file using ksh | meghana | Shell Programming and Scripting | 3 | 04-16-2008 12:04 PM |
| How to edit env file | duke0001 | UNIX for Advanced & Expert Users | 3 | 02-16-2007 11:43 AM |
| file edit help | sentak | Shell Programming and Scripting | 10 | 11-14-2006 08:20 AM |
| Edit an ISO / dd file? | WIntellect | Filesystems, Disks and Memory | 4 | 11-20-2002 05:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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.) |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|