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
UNISAP(3)						   BSD Library Functions Manual 						 UNISAP(3)

NAME
unimsg, unisve_check_addr, unisve_check_selector, unisve_check_blli_id2, unisve_check_blli_id3, unisve_check_bhli, unisve_check_sap, unisve_overlap_addr, unisve_overlap_selector, unisve_overlap_blli_id2, unisve_overlap_blli_id3, unisve_overlap_bhli, unisve_overlap_sap, unisve_is_catchall, unisve_match -- ATM signalling library - ATM SAP handling LIBRARY
Begemot ATM signalling library (libunimsg, -lunimsg) SYNOPSIS
#include <uni4/unisap.h> int unisve_check_addr(const struct unisve_addr *sve); int unisve_check_selector(const struct unisve_selector *sve); int unisve_check_blli_id2(const struct unisve_blli_id2 *sve); int unisve_check_blli_id3(const struct unisve_blli_id3 *sve); int unisve_check_bhli(const struct unisve_bhli *sve); int unisve_check_sap(const struct uni_sap *sve); int unisve_overlap_addr(const struct unisve_addr *sve1, const struct unisve_addr *sve2); int unisve_overlap_selector(const struct unisve_selector *sve1, const struct unisve_selector *sve2); int unisve_overlap_blli_id2(const struct unisve_blli_id2 *sve1, const struct unisve_blli_id2 *sve2); int unisve_overlap_blli_id3(const struct unisve_blli_id3 *sve1, const struct unisve_blli_id3 *sve2); int unisve_overlap_bhli(const struct unisve_bhli *sve1, const struct unisve_bhli *sve2); int unisve_overlap_sap(const struct uni_sap *sap1, const struct uni_sap *sap2); int unisve_is_catchall(const struct uni_sap *sap); int unisve_match(const struct uni_sap *sap, const struct uni_ie_called *called, const struct uni_ie_blli *blli, const struct uni_ie_bhli *bhli); DESCRIPTION
The unimsg library contains functions to handle Service Access Points (SAP) and SAP Vector Elements (SVE) as specified in the ATM Forum ATM API Semantic Description. SAPs are the analog of TCP and UDP ports in the ATM world. As usually in ATM they are a couple of orders of mag- nitude more complex as their Internet equivalent. See the ATM Forum document for a description. A SAP is a data structure: struct uni_sap { struct unisve_addr addr; struct unisve_selector selector; struct unisve_blli_id2 blli_id2; struct unisve_blli_id3 blli_id3; struct unisve_bhli bhli; }; that consists of 5 elements matching different information elements in the SETUP message. Each of these elements has a tag that defines how the SVE is to be matched with the information element. The tag is one of UNISVE_ABSENT The information element has to absent from the SETUP message. UNISVE_PRESENT The information element has to be present in the SETUP message and must match the SVE. UNISVE_ANY The information element may be absent from the SETUP message or may have any value. The called address is matched by a struct unisve_addr { enum unisve_tag tag; enum uni_addr_type type;/* type of address */ enum uni_addr_plan plan;/* addressing plan */ uint32_t len; /* length of address */ u_char addr[UNI_ADDR_MAXLEN]; }; Here type is the type of address and plan is the address plan. len is the length of the address (for ATME addresses not counting the selec- tor byte) and addr is the address itself. In case of ATME addresses the selector byte is matched by a struct unisve_selector { enum unisve_tag tag; uint8_t selector; }; Here selector is the selector byte that must match the 20th byte of the ATME calling address from the SETUP message. The BLLI information element is matched by two SVEs: one for layer 2 options and one for layer 3 options. The layer 2 SVE is: struct unisve_blli_id2 { enum unisve_tag tag; uint8_t proto:5;/* the protocol */ uint8_t user:7; /* user specific protocol */ }; Where the user fields is matched only if the proto field specifies UNI_BLLI_L2_USER. The layer 3 SVE is: struct unisve_blli_id3 { enum unisve_tag tag; uint8_t proto:5;/* L3 protocol */ uint8_t user:7; /* user specific protocol */ uint8_t ipi:8; /* ISO/IEC TR 9557 IPI */ uint32_t oui:24; /* IEEE 802.1 OUI */ uint32_t pid:16; /* IEEE 802.1 PID */ uint32_t noipi; /* ISO/IEC TR 9557 per frame */ }; For the exact rules how matching occures refer to the source code or the ATM Forum document. Finally the BHLI information element is matched with a struct unisve_bhli { enum unisve_tag tag; enum uni_bhli type; /* type of info */ uint32_t len; /* length of info */ uint8_t info[8];/* info itself */ }; For each SVE type there is a function that checks whether the SVE is correct specified. The functions unisve_check_addr(), unisve_check_selector(), unisve_check_blli_id2(), unisve_check_blli_id3(), and unisve_check_bhli() return one of the following error codes: enum { UNISVE_OK = 0, UNISVE_ERROR_BAD_TAG, UNISVE_ERROR_TYPE_PLAN_CONFLICT, UNISVE_ERROR_ADDR_SEL_CONFLICT, UNISVE_ERROR_ADDR_LEN, UNISVE_ERROR_BAD_ADDR_TYPE, UNISVE_ERROR_BAD_BHLI_TYPE, UNISVE_ERROR_BAD_BHLI_LEN, }; A code of UNISVE_OK means that the SVE has no error. The function unisve_check_sap() checks a complete SAP and returns one of the above codes. There is a definition UNISVE_ERRSTR that evaluates to a comma separated list of strings that can be used to initializes an array of char pointers to map the error codes into human readable strings. The ATM Forum document defines the concept of overlaping SAPs. This basically means, that an incoming SETUP could match more than one SAP (and more than one application) to receive the SETUP. For each SVE type there is a function that checks whether two SVEs overlap and there is a function that checks whether two SAPs overlap. The functions unisve_overlap_addr(), unisve_overlap_selector(), unisve_overlap_blli_id2(), unisve_overlap_blli_id3(), unisve_overlap_bhli(), and unisve_overlap_sap() return 1 if the SVEs or SAPs overlap and 0 if they do not. They assume, that the SAPs are correct. The ATM Forum document specifies a catch-all SAP. The function unisve_is_catchall() returns 1 if the SAP is the catch-all SAP and 0 other- wise. Finally the function unisve_match() is used to match a SAP against the information elements from a SETUP message. It returns 1 if they match and 0 otherwise. SEE ALSO
libunimsg(3) AUTHORS
Hartmut Brandt <harti@FreeBSD.org> BSD
June 14, 2005 BSD
All times are GMT -4. The time now is 08:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy