I want match pattern after which another pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I want match pattern after which another pattern
# 1  
Old 01-09-2009
I want match pattern after which another pattern

Dear Experts,
I have a plugin file. I want match a pattern for example "stageApp90Node01_Stgcorporate90" . After which i want match Server-Cluster which above this pattern. I bolded the pattern. Please help me .

Code:
<ServerCluster CloneSeparatorChange="false" GetDWLMTable="false" IgnoreAffinityRequests="true" LoadBalance="Round Robin" Name="Stgcorporate" PostBufferSize="64" PostSizeLimit="-1" RemoveSpecialHeaders="true" RetryInterval="60">
      <Server CloneID="138sl4mmh" ConnectTimeout="0" ExtendedHandshake="false" LoadBalanceWeight="2" MaxConnections="-1" Name="stageApp90Node01_Stgcorporate90" ServerIOTimeout="0" WaitForContinue="false">
         <Transport Hostname="stageApp90" Port="9082" Protocol="http"/>
         <Transport Hostname="stageApp90" Port="9445" Protocol="https">
            <Property Name="keyring" Value="/opt/IBM/HTTPServer/Plugins/config/stageWeb133/plugin-key.kdb"/>
            <Property Name="stashfile" Value="/opt/IBM/HTTPServer/Plugins/config/stageWeb133/plugin-key.sth"/>
         </Transport>
      </Server>
      <Server CloneID="138svpeh2" ConnectTimeout="0" ExtendedHandshake="false" LoadBalanceWeight="2" MaxConnections="-1" Name="StageApp91Node01_Stgcorporate91" ServerIOTimeout="0" WaitForContinue="false">
         <Transport Hostname="StageApp91" Port="9082" Protocol="http"/>
         <Transport Hostname="StageApp91" Port="9445" Protocol="https">
            <Property Name="keyring" Value="/opt/IBM/HTTPServer/Plugins/config/stageWeb133/plugin-key.kdb"/>
            <Property Name="stashfile" Value="/opt/IBM/HTTPServer/Plugins/config/stageWeb133/plugin-key.sth"/>
         </Transport>
      </Server>
      <PrimaryServers>
         <Server Name="stageApp90Node01_Stgcorporate90"/>
         <Server Name="StageApp91Node01_Stgcorporate91"/>
      </PrimaryServers>
   </ServerCluster>
   <ServerCluster CloneSeparatorChange="false" GetDWLMTable="false" IgnoreAffinityRequests="true" LoadBalance="Round Robin" Name="Stggls" PostBufferSize="64" PostSizeLimit="-1" RemoveSpecialHeaders="true" RetryInterval="60">
      <Server CloneID="138sld7tf" ConnectTimeout="0" ExtendedHandshake="false" LoadBalanceWeight="2" MaxConnections="-1" Name="stageApp90Node01_Stggls90" ServerIOTimeout="0" WaitForContinue="false">
         <Transport Hostname="stageApp90" Port="9085" Protocol="http"/>
         <Transport Hostname="stageApp90" Port="9448" Protocol="https">
            <Property Name="keyring" Value="/opt/IBM/HTTPServer/Plugins/config/stageWeb133/plugin-key.kdb"/>
            <Property Name="stashfile" Value="/opt/IBM/HTTPServer/Plugins/config/stageWeb133/plugin-key.sth"/>
         </Transport>
      </Server>
      <Server CloneID="138sldamf" ConnectTimeout="0" ExtendedHandshake="false" LoadBalanceWeight="2" MaxConnections="-1" Name="StageApp91Node01_Stggls91" ServerIOTimeout="0" WaitForContinue="false">
         <Transport Hostname="StageApp91" Port="9085" Protocol="http"/>
         <Transport Hostname="StageApp91" Port="9448" Protocol="https">
            <Property Name="keyring" Value="/opt/IBM/HTTPServer/Plugins/config/stageWeb133/plugin-key.kdb"/>
            <Property Name="stashfile" Value="/opt/IBM/HTTPServer/Plugins/config/stageWeb133/plugin-key.sth"/>
         </Transport>
      </Server>
      <PrimaryServers>
         <Server Name="stageApp90Node01_Stggls90"/>
         <Server Name="StageApp91Node01_Stggls91"/>
      </PrimaryServers>
   </ServerCluster>

Thanks & Regards
Naresh

Last edited by zaxxon; 01-09-2009 at 02:56 AM.. Reason: Added code tags
# 2  
Old 01-09-2009
After matching both, what should be the output displayed?

Also use [ code ] and [ /code ] tags to make your code/logs/data more readalbe, thank you. It is also the hash icon in the options bar above the editing window when typing a post. I edited your post so you can see what I mean.
# 3  
Old 01-09-2009
The output Needed

After Matching <ServerCluster> tag i want to get the Server Clone Id's ie.

<Server CloneID=> and i want to change Load the Balance weight

Regards
Naresh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

2. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

3. Shell Programming and Scripting

sed : match one pattern then the next consecutive second pattern not working

Ive used this snippet of code on a solaris box thousands of times. But it isnt working on the new linux box sed -n '/interface LoopBack0/{N;/ ip address /p;}' *.conf its driving me nuts !! Is there something Im missing ? (7 Replies)
Discussion started by: popeye
7 Replies

4. Shell Programming and Scripting

Pattern match exclusive return pattern/variable

I have an application(Minecraft Server) that generates a logfile live. Using Crontab and screen I send a 'list' command every minute. Sample Log view: 2013-06-07 19:14:37 <Willrocksyea1> hello* 2013-06-07 19:14:41 <Gromden29> hey 2013-06-07 19:14:42 Gromden29 lost connection:... (1 Reply)
Discussion started by: gatekeeper258
1 Replies

5. UNIX for Dummies Questions & Answers

Match Pattern after certain pattern and Print words next to Pattern

Hi experts , im new to Unix,AWK ,and im just not able to get this right. I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Discussion started by: 100bees
2 Replies

6. Shell Programming and Scripting

Awk to match a pattern and perform a search after the first pattern

Hello Guyz I have been following this forum for a while and the solutions provided are super useful. I currently have a scenario where i need to search for a pattern and start searching by keeping the first pattern as a baseline ABC DEF LMN EFG HIJ LMN OPQ In the above text i need to... (8 Replies)
Discussion started by: RickCharles
8 Replies

7. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

8. Shell Programming and Scripting

pattern match and replace another pattern in same line

I have a pattern username:x:32005:32006::/usr/local/user:/bin/bash I need to match the line containing username and replace /bin/bash with /usr/local/my/bin/noshell So it becomes username:x:32005:32006::/usr/local/user:/usr/local/my/bin/noshell (7 Replies)
Discussion started by: anilcliff
7 Replies

9. Shell Programming and Scripting

AWK match $1 $2 pattern in file 1 to $1 $2 pattern in file2

Hi, I have 2 files that I have modified to basically match each other, however I want to determine what (if any) line in file 1 does not exist in file 2. I need to match column $1 and $2 as a single string in file1 to $1 and $2 in file2 as these two columns create a match. I'm stuck in an AWK... (9 Replies)
Discussion started by: right_coaster
9 Replies

10. Shell Programming and Scripting

Use to awk to match pattern, and print the pattern

Hi, I know how to use awk to search some expressions like five consecutive numbers, , this is easy. However, how do I make awk print the pattern that is been matched? For example: input: usa,canada99292,japan222,france59664,egypt223 output:99292,59664 (6 Replies)
Discussion started by: grossgermany
6 Replies
Login or Register to Ask a Question