The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts 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 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 07:43 AM
file edit help sentak Shell Programming and Scripting 10 11-14-2006 04:20 AM
Edit an ISO / dd file? WIntellect Filesystems, Disks and Memory 4 11-20-2002 01:21 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-17-2008
Registered User
 

Join Date: Feb 2006
Posts: 3
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-17-2008
era
Guest
 

Posts: n/a
sed allows alternative separators for precisely this reason.

Code:
sed -e "s%${ORACLE_SID}:${ORACLE_HOME}%${ORACLE_SID}:${NEW_HOME}%g
It's "turtles all the way down" if you can't find a character which is guaranteed not to be in the replacement strings, though.

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.)
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0