Cutting number from range in xml file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cutting number from range in xml file
# 1  
Old 07-24-2005
Cutting number from range in xml file

Hi folks,

I need to find the following value:
First,I need to find the starting section by finding the line:
Code:
<process-type id="OC4J_RiGHTv_${SCHEMA_NAME}" module-id="OC4J">

Second,under this line I need to find the following line:
Code:
<port id="rmi" range="3765-3776"/>

And third,from this line I need to cut the first number in the line. In this case it is 3765"

The section in the xml file looks as the following:
Code:
<process-type id="OC4J_RiGHTv_IAS10G" module-id="OC4J">
               <environment>
                  <variable id="LD_LIBRARY_PATH" value="/home/ias/v10.1.2/lib" append="true"/>
                  <variable id="SHLIB_PATH" value="/home/ias/v10.1.2/lib32" append="true"/>
               </environment>
               <module-data>
                  <category id="start-parameters">
                     <data id="java-options" value="-server -Djava.security.policy=/home/ias/v10.1.2/j2ee/OC4J_RiGHTv_IAS10G/config/java2.policy -Djava.awt.headless=true -Drightv.root=/home/ias/v10.1.2/j2ee/OC4J_RiGHTv_IAS10G -Xmx512M -Duser.timezone=GMT+03:00"/>
                     <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/OC4J_RiGHTv_IAS10G/config/java2.policy -Djava.awt.headless=true -Drightv.root=/home/ias/v10.1.2/j2ee/OC4J_RiGHTv_IAS10G -Xmx512M -Duser.timezone=GMT+03:00"/>
                  </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="3765-3776"/>
               <port id="jms" range="3295-3296"/>
               <process-set id="default_island" numprocs="1"/>
            </process-type

>

$SCHEMA_NAME=IAS10G
How can I assign the first number in the range of rmi ports (3765 in this section) into a parameter?

Thanks in advance,
Nir
# 2  
Old 07-25-2005
Try this.

Code:
sed -n '/process-type id="'"OC4J_RiGHTv_${SCHEMA_NAME}"'"/,/<\/process-type>/{ s/<port id="rmi".*\([0-9]\{4\}\)-.*/\1/p }' input.xml

Vino

Last edited by vino; 07-25-2005 at 01:36 AM..
# 3  
Old 07-25-2005
Hey vino !

It's amazing command!!
It works fantastic!
No doubt that you are a sed expert!

Thanks a lot!

Best regards,
Nir
# 4  
Old 07-25-2005
# 5  
Old 07-25-2005
Thanks again vino!
It will be very helpfull.

Nir
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

I need to find in a file a list of number where last two digit end in a range

I all I am tryng to find a way to sort a list of number in a file by the value of last two digit. i have a list like this 313202320388 333202171199 373202164587 393202143736 323202132208 353201918107 343201887399 363201810249 333201805043 353201791691 (7 Replies)
Discussion started by: rattoeur
7 Replies

2. Shell Programming and Scripting

Cutting all xml tags out of a line

I would like search and find a word (easily identified by 'key') from an xml file and then cut all of the tags out of the resulting line (anything between a < and a >) and display the remaining material. I am running Debian and mksh shell. dictionary.sh: #!/bin/sh key='key="'$1'"><form'... (3 Replies)
Discussion started by: bedtime
3 Replies

3. Solaris

File System Error: BAD SUPERBLOCK AT BLOCK 16: NUMBER OF DIRECTORIES OUT OF RANGE

Hi All, we are having a file system error in one of our servers. The server failed to boot in usual user mode. Instead boot with single user mode and requesting to run a FSCK manually to repair the corrupted. see the below output. Netra T2000, No Keyboard Copyright 2008 Sun Microsystems,... (5 Replies)
Discussion started by: Buddhike G
5 Replies

4. Shell Programming and Scripting

Cutting a column and pasting its number

Hello Gurus, This is my first ever post here. I tried looking for similar material but came up empty handed. Apologies if this is too verbose or if I'm not using the correct formatting. I have files containing a fixed number of elements per line; separator is a single space. Each line has the... (4 Replies)
Discussion started by: stdroid
4 Replies

5. Shell Programming and Scripting

Splitting XML file on basis of line number into multiple file

Hi All, I have more than half million lines of XML file , wanted to split in four files in a such a way that top 7 lines should be present in each file on top and bottom line of should be present in each file at bottom. from the 8th line actual record starts and each record contains 15 lines... (14 Replies)
Discussion started by: ajju
14 Replies

6. Shell Programming and Scripting

Number of columns in xml file

How to find the number of columns in xml file. i tried following command. #!bin/ksh cat $1 | grep -c "</mdm:attribute>" exit 0 but i am not getting accurate result which is not matching with the manual count. data format : <mdm:attribute> value </mdm:attribute> (6 Replies)
Discussion started by: victory
6 Replies

7. AIX

How to find number of columns in xml file?

How to find the number of columns in xml file. i tried following command. Code: #!bin/ksh cat $1 | grep -c "</mdm:attribute>"exit 0but i am not getting accurate result which is not matching with the manual count. data format : Code: <mdm:attribute> value </mdm:attribute> No... (1 Reply)
Discussion started by: victory
1 Replies

8. Shell Programming and Scripting

extract number range from a file

Hi Everyone, a.txt 1272904667;1272904737;1 1272904747;1272904819;1 1272904810;1272904857;1 1272904889;1272904926;1 1272905399;1272905406;1 1272905411;1272905422;1 if i want to get the record, when the a.txt 1st field is between 1272904749 and 1272905399, any simple way by using awk,... (1 Reply)
Discussion started by: jimmy_y
1 Replies

9. UNIX for Dummies Questions & Answers

Extract a specific number from an XML file based on the start and end tags

Hello People, I have the following contents in an XML file ........... ........... .......... ........... <Details = "Sample Details"> <Name>Bob</Name> <Age>34</Age> <Address>CA</Address> <ContactNumber>1234</ContactNumber> </Details> ........... ............. .............. (4 Replies)
Discussion started by: sushant172
4 Replies

10. Shell Programming and Scripting

extract a number within an xml file

Hi Everyone, I have an sh script that I am working on and I have run into a little snag that I am hoping someone here can assist me with. I am using wget to retrieve an xml file from thetvdb.com. This part works ok but what I need to be able to do is extract the series ID # from the xml and put... (10 Replies)
Discussion started by: tret
10 Replies
Login or Register to Ask a Question