Sponsored Content
Top Forums Shell Programming and Scripting awk command to get file content until 2 occurrence of pattern match Post 302976240 by prince1987 on Sunday 26th of June 2016 06:49:15 PM
Old 06-26-2016
awk command to get file content until 2 occurrence of pattern match

AWK command to get file content until 3 occurrence of pattern match,


INPUT FILE:

Code:
JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<custOptIn xmlns="http://com/walm/ta/cu/ccs/xml2">
    <person>Romi</person>
    <appName>SAP</appName>
</custOptIn>

JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<custOptIn xmlns="http://com/walm/ta/cu/ccs/xml3">
    <person>Anja</person>
    <appName>SAP</appName>
</custOptIn>

JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<custOptIn xmlns="http://com/walm/ta/cu/ccs/xml1">
    <person>Rohit</person>
    <appName>SAP</appName>
</custOptIn>

JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<custOptIn xmlns="http://com/walm/ta/cu/ccs/xml">
    <person>Roho</person>
    <appName>SAP</appName>
</custOptIn>


Can you help me to get awk command to print lines three occurrence of JMS_BODY_FIELD



Example output should be:

Code:
JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<custOptIn xmlns="http://com/walm/ta/cu/ccs/xml2">
    <person>Romi</person>
    <appName>SAP</appName>
</custOptIn>

JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<custOptIn xmlns="http://com/walm/ta/cu/ccs/xml3">
    <person>Anja</person>
    <appName>SAP</appName>
</custOptIn>

JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<custOptIn xmlns="http://com/walm/ta/cu/ccs/xml1">
    <person>Rohit</person>
    <appName>SAP</appName>
</custOptIn>


Last edited by Don Cragun; 06-26-2016 at 10:07 PM.. Reason: Change B and U tags to ICODE tags; change I tags and I and COLOR tags to CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk/sed/perl command to delete specific pattern and content above it...

Hi, Below is my input file: Data: 1 Length: 20 Got result. Data: 2 Length: 30 No result. Data: 3 Length: 20 (7 Replies)
Discussion started by: edge_diners
7 Replies

2. Shell Programming and Scripting

fetch last line no form file which is match with specific pattern by grep command

Hi i have a file which have a pattern like this Nov 10 session closed Nov 10 Nov 9 08:14:27 EST5EDT 2010 on tty . Nov 10 Oct 19 02:14:21 EST5EDT 2010 on pts/tk . Nov 10 afrtetryytr Nov 10 session closed Nov 10 Nov 10 03:21:04 EST5EDT 2010 Dec 8 Nov 10 05:03:02 EST5EDT 2010 ... (13 Replies)
Discussion started by: Himanshu_soni
13 Replies

3. 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

4. Shell Programming and Scripting

Match from one pattern to second occurrence of second pattern

Given an XML file that contains (NOT "consists of"): </dict> <key>system.</key> <dict> <key>rule</key> <string>default</string> </dict> <key>system.burn</key> ... (9 Replies)
Discussion started by: jnojr
9 Replies

5. Shell Programming and Scripting

awk Pattern Match One File to Another

I want to read from file 1 and pattern match in file two and print field two from the next line. File 1: user1 user2 user3 File 2: name=user1 gud=12345 name=user2 gud=32456 I have this pattern hardcoded but can't work out how to pass file 1 to the pattern match: (6 Replies)
Discussion started by: u20sr
6 Replies

6. Shell Programming and Scripting

Sorting content between match pattern and move on with awk and sed

S 0.0 0.0 (reg, inst050) k e f d c S 0.0 0.0 (mux, m030) k g r s x v S 0.0 0.0 (reg, inst020) q s n m (12 Replies)
Discussion started by: ctphua
12 Replies

7. Shell Programming and Scripting

Insert content of file before the first occurrence of a line starts with a pattern in another file

Hi all, I'm new to scripting.. facing some problems while inserting content of a file into another file... I want to insert content of a file (file2) into file1, before first occurrence of "line starts with pattern" in file1 file1 ====== working on linux its unix world working on... (14 Replies)
Discussion started by: Jagadeesh Kumar
14 Replies

8. Shell Programming and Scripting

awk to update value based on pattern match in another file

In the awk, thanks you @RavinderSingh13, for the help in below, hopefully it is close as I am trying to update the value in $12 of the tab-delimeted file2 with the matching value in $1 of the space delimeted file1. I have added comments for each line as well. Thank you :). awk awk '$12 ==... (10 Replies)
Discussion started by: cmccabe
10 Replies

9. Shell Programming and Scripting

awk to extract and print first occurrence of pattern in each line

I am trying to use awk to extract and print the first ocurrence of NM_ and NP_ with a : before in each line. The input file is tab-delimeted, but the output does not need to be. The below does execute but prints all the lines in the file not just the patterns. Thank you :). file tab-delimeted ... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

sed print from last occurrence match until the end of last occurrence match

Hi, i have file file.txt with data like: START 03:11:30 a 03:11:40 b END START 03:13:30 eee 03:13:35 fff END jjjjjjjjjjjjjjjjjjjjj START 03:14:30 eee 03:15:30 fff END ggggggggggg iiiiiiiiiiiiiiiiiiiiiiiii I want the below output START (13 Replies)
Discussion started by: Jyotshna
13 Replies
OCF_HEARTBEAT_SAPDAT(7) 					OCF resource agents					   OCF_HEARTBEAT_SAPDAT(7)

NAME
ocf_heartbeat_SAPDatabase - Manages any SAP database (based on Oracle, MaxDB, or DB2) SYNOPSIS
SAPDatabase [start | stop | status | monitor | meta-data | validate-all] DESCRIPTION
Resource script for SAP databases. It manages a SAP database of any type as an HA resource. SUPPORTED PARAMETERS
SID The unique SAP system identifier. e.g. P01 (unique, required, string, no default) DIR_EXECUTABLE The full qualified path where to find sapstartsrv and sapcontrol. (unique, optional, string, no default) DBTYPE The name of the database vendor you use. Set either: ORA,DB6,ADA (unique, required, string, no default) NETSERVICENAME The Oracle TNS listener name. (unique, optional, string, no default) DBJ2EE_ONLY If you do not have a ABAP stack installed in the SAP database, set this to TRUE (unique, optional, boolean, default false) JAVA_HOME This is only needed if the DBJ2EE_ONLY parameter is set to true. Enter the path to the Java SDK which is used by the SAP WebAS Java (unique, optional, string, no default) STRICT_MONITORING This controls how the resource agent monitors the database. If set to true, it will use SAP tools to test the connect to the database. Do not use with Oracle, because it will result in unwanted failovers in case of an archiver stuck (unique, optional, boolean, default false) AUTOMATIC_RECOVER The SAPDatabase resource agent tries to recover a failed start attempt automatically one time. This is done by running a forced abort of the RDBMS and/or executing recovery commands. (unique, optional, boolean, default false) DIR_BOOTSTRAP The full qualified path where to find the J2EE instance bootstrap directory. e.g. /usr/sap/P01/J00/j2ee/cluster/bootstrap (unique, optional, string, no default) DIR_SECSTORE The full qualified path where to find the J2EE security store directory. e.g. /usr/sap/P01/SYS/global/security/lib/tools (unique, optional, string, no default) DB_JARS The full qualified filename of the jdbc driver for the database connection test. It will be automatically read from the bootstrap.properties file in Java engine 6.40 and 7.00. For Java engine 7.10 and higher the parameter is mandatory. (unique, optional, string, no default) PRE_START_USEREXIT The full qualified path where to find a script or program which should be executed before this resource gets started. (unique, optional, string, no default) POST_START_USEREXIT The full qualified path where to find a script or program which should be executed after this resource got started. (unique, optional, string, no default) PRE_STOP_USEREXIT The full qualified path where to find a script or program which should be executed before this resource gets stopped. (unique, optional, string, no default) POST_STOP_USEREXIT The full qualified path where to find a script or program which should be executed after this resource got stopped. (unique, optional, string, no default) SUPPORTED ACTIONS
This resource agent supports the following actions (operations): start Starts the resource. Suggested minimum timeout: 1800. stop Stops the resource. Suggested minimum timeout: 1800. status Performs a status check. Suggested minimum timeout: 60. monitor Performs a detailed status check. Suggested minimum timeout: 60. Suggested interval: 120. validate-all Performs a validation of the resource configuration. Suggested minimum timeout: 5. meta-data Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5. methods Suggested minimum timeout: 5. EXAMPLE
The following is an example configuration for a SAPDatabase resource using the crm(8) shell: primitive p_SAPDatabase ocf:heartbeat:SAPDatabase params SID=string DBTYPE=string op monitor depth="0" timeout="60" interval="120" SEE ALSO
http://www.linux-ha.org/wiki/SAPDatabase_(resource_agent) AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors) resource-agents UNKNOWN 03/09/2014 OCF_HEARTBEAT_SAPDAT(7)
All times are GMT -4. The time now is 11:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy