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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Adding a columnfrom a specifit line number to a specific line number Ezy Shell Programming and Scripting 2 05-12-2008 09:29 AM
Match keyword on string and substitute under vi lycaon Shell Programming and Scripting 2 04-25-2008 01:36 PM
Appending line number to each line and getting total number of lines chiru_h Shell Programming and Scripting 2 03-25-2008 10:19 AM
grep the string with the line number salaathi Shell Programming and Scripting 4 12-04-2007 11:42 AM
Failed to substitute string with "<>" nir_s Shell Programming and Scripting 4 08-02-2005 07:52 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-19-2005
nir_s nir_s is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 148
substitute string according line number

Hi all,

I have an xml file which have several sections as the following:

<process-type id="NIR" module-id="OC4J">
<module-data>
<category id="start-parameters">
<data id="java-options" value="-server -Djava.security.policy=/home/ias/v10.1.2/j2ee/NIR/config/java2.policy -Djava.awt.headless=true"/>
<data id="oc4j-options" value="-properties"/>
</category>
<category id="stop-parameters">
<data id="java-options" value="-Djava.security.policy=/home/ias/v10.1.2/j2ee/NIR/config/java2.policy -Djava.awt.headless=true"/>
</category>
</module-data>
<start timeout="900" retry="2"/>
<stop timeout="120"/>
<restart timeout="720" retry="2"/>
<port id="ajp" range="3301-3400"/>
<port id="rmi" range="3201-3300"/>
<port id="jms" range="3701-3800"/>
<process-set id="default_island" numprocs="1"/>
</process-type>

Each section start with <process-type id="NIR" module-id="OC4J">
($SCHEMA_NAME=NIR) and ends with </process-type>

I need to substitute the range ports in the lines:
<port id="rmi" range="3201-3300"/>
<port id="jms" range="3701-3800"/>

I cannot do it with sed globally because it will substitute all the appearances in the file.
I can find the first line by grepping: process-type id=\"$SCHEMA_NAME\"
After that going down 14 lines and 15 lines and substituting the ports.

The question is : does "sed" know to get line number and replace the string in the specific line?

Thanks in advance,
Nir
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0