![]() |
|
|
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 |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|