Sponsored Content
Top Forums Shell Programming and Scripting Extract and parse data between two strings Post 302407043 by jaygamini on Wednesday 24th of March 2010 11:54:35 AM
Old 03-24-2010
Extract and parse data between two strings

Hi , I have a billing CDR file which is separated by “!”. I need to extract and format data between the starting (“!”) and the end of the line (“1.2.1.8”). These two variables are permanent tags to show begin and end.

! TICKET NBR : 2 ! GSI : 101 ! 3100.2.112.1 24/03/2010 00:41:14 ! 3100.2.105.6 Mobility ! 1.2.1.5 24/03/2010 00:41:14 ! 3100.2.19.5 302619135190023 ! 3100.2.70.15 101R=241234541717 ! 3100.2.19.7 99135190023 ! 3100.2.984.50 A18 ! 3100.2.104.4 acc_22640957031006 ! 3100.2.24.1 20 ! 3100.2.140.1 100 ! 3100.2.142.1 100 ! 100.6.5.1 1 ! 3100.2.106.1 SMS_ALWAYS_ALLOWED ! 100.6.5.2 1 ! 449032008 labl301 ! 3100.2.22.1 SMSMT ! 3100.2.20.1 9135190023 ! 3100.2.13.1 0.00 ! 3100.2.14.2 0 ! 1.2.1.8

(1) On the starting, the first two parameters are separated by semicolon (“:”) but still separated by “!”
(2) And, rest of them are separated by 4 digit number (ex: X.X.X.X <blank space> Output)” followed by return result. I want to have the output like

TICKET NBR : 2
GSI : 101
3100.2.112.1 : 24/03/2010 00:41:14
3100.2.105.6 : Mobility
1.2.1.5 : 24/03/2010 00:41:14
.
.
.(Last 3 )
3100.2.20.1: 9135190023
3100.2.13.1 : 0.00
3100.2.14.2 : 0


I am looking for a single awk/sed command to parse this information. The above example is a single line output. Any help will be greatly appreciated.
Gamini
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse apart strings of comma separated data with varying number of fields

I have a situation where I am reading a text file line-by-line. Those lines of data contain comma separated fields of data. However, each line can vary in the number of fields it can contain. What I need to do is parse apart each line and write each field of data found (left to right) into a file.... (7 Replies)
Discussion started by: 2reperry
7 Replies

2. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

3. Shell Programming and Scripting

Extract specific data content from a long list of data

My input: Data name: ABC001 Data length: 1000 Detail info Data Direction Start_time End_time Length 1 forward 10 100 90 1 forward 15 200 185 2 reverse 50 500 450 Data name: XFG110 Data length: 100 Detail info Data Direction Start_time End_time Length 1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies

4. Shell Programming and Scripting

Extract data between two strings

Hi , I have a billing CDR file which has repeated lines as indicated below and I need to extract data between two strings (i.e.: <?> and </?>). Eventually, map that information with the corresponding field. I'm new to unix, any help will be greatly appreciated. Gamini Input (single line): !... (3 Replies)
Discussion started by: jaygamini
3 Replies

5. Shell Programming and Scripting

Search and Extract data between two strings

hi, In a given directory, i need to search for a string (eg:ABCD). For a given file, i have to extract the text between START and END strings . I need to extract all the text between START and END and there can be multiple START and END in a file. Sample: There is a directort... (3 Replies)
Discussion started by: flamingo_l
3 Replies

6. Shell Programming and Scripting

Extract and parse XML data (statistic value) to csv

Hi All, I need to parse some statistic data from the "measInfo" -eg. 25250000 (as highlighted) and return the result into line by line, and erasing all other unnecessary info/tag. Thought of starting with grep "measInfoID="25250000" but this only returns 1 line. How do I get all the output... (8 Replies)
Discussion started by: jackma
8 Replies

7. Shell Programming and Scripting

Extract/Parse information from html (website)

Hello, I want to extract some informations from a html (website, http://www.energiecontracting.de/7-mitglieder/von-A-Z.php?a_z=B&seite=2 ) file and save those in a predefined format (.csv).. However it seems that the code on that website is kinda messy and I can't find a way to handle it... (5 Replies)
Discussion started by: TehOne
5 Replies

8. Shell Programming and Scripting

Extract two strings from a file and create a new file with these strings

I have the following lines in a log file. It would be great if some one can help me to create a new file with the just entries in the below format. 66.150.161.195 HPSAC=Z05 66.150.161.196 HPSAC=A05 That is just extract the IP address and the string DPSAC=its value 66.150.161.195 -... (1 Reply)
Discussion started by: Tuxidow
1 Replies

9. Shell Programming and Scripting

Parse Page Source and Extract Links

Hi Friends, I have a bunch of URLs. Each URL will open up an abstract page. But, the source contains a link to the main PDF article. I am looking for a script to do the following task 1. Read input file with URLs. 2. Parse the source and grab all the lines that has the word 'PDF'.... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

10. UNIX for Dummies Questions & Answers

Issue when using egrep to extract strings (too many strings)

Dear all, I have a data like below (n of rows=400,000) and I want to extract the rows with certain strings. I use code below. It works if there is not too many strings for example n of strings <5000. while I have 90,000 strings to extract. If I use the egrep code below, I will get error: ... (3 Replies)
Discussion started by: forevertl
3 Replies
IPSEC_SPI(8)							  [FIXME: manual]						      IPSEC_SPI(8)

NAME
ipsec_spi - manage IPSEC Security Associations SYNOPSIS
Note: In the following, <SA> means: --af (inet | inet6) --edst daddr --spi spi --proto proto OR --said said, <life> means: --life (soft | hard) allocations | bytes | addtime | usetime | packets | [value...] <SA> --src src --ah (hmac-md5-96 | hmac-sha1-96) [--replay_window replayw] [<life>] --authkey akey ipsec spi <SA> --src src --esp (3des | 3des-md5-96 | 3des-sha1-96) [--replay_window replayw] [<life>] --enckey ekey ipsec spi <SA> --src src --esp [--replay_window replayw] [<life>] --enckey ekey --authkey akey ipsec spi <SA> --src src --comp deflate ipsec spi <SA> --ip4 --src encap-src --dst encap-dst ipsec spi <SA> --ip6 --src encap-src --dst encap-dst ipsec spi <SA> --del ipsec spi --help ipsec spi --version ipsec spi --clear DESCRIPTION
Spi creates and deletes IPSEC Security Associations. A Security Association (SA) is a transform through which packet contents are to be processed before being forwarded. A transform can be an IPv4-in-IPv4 or an IPv6-in-IPv6 encapsulation, an IPSEC Authentication Header (authentication with no encryption), or an IPSEC Encapsulation Security Payload (encryption, possibly including authentication). When a packet is passed from a higher networking layer through an IPSEC virtual interface, a search in the extended routing table (see ipsec_eroute(8)) yields an effective destination address, a Security Parameters Index (SPI) and a IP protocol number. When an IPSEC packet arrives from the network, its ostensible destination, an SPI and an IP protocol specified by its outermost IPSEC header are used. The destination/SPI/protocol combination is used to select a relevant SA. (See ipsec_spigrp(8) for discussion of how multiple transforms are combined.) The af, daddr, spi and proto arguments specify the SA to be created or deleted. af is the address family (inet for IPv4, inet6 for IPv6). Daddr is a destination address in dotted-decimal notation for IPv4 or in a coloned hex notation for IPv6. Spi is a number, preceded by '0x' for hexadecimal, between 0x100 and 0xffffffff; values from 0x0 to 0xff are reserved. Proto is an ASCII string, "ah", "esp", "comp" or "tun", specifying the IP protocol. The protocol must agree with the algorithm selected. Alternatively, the said argument can also specify an SA to be created or deleted. Said combines the three parameters above, such as: "tun.101@1.2.3.4" or "tun:101@1:2::3:4", where the address family is specified by "." for IPv4 and ":" for IPv6. The address family indicators substitute the "0x" for hexadecimal. The source address, src, must also be provided for the inbound policy check to function. The source address does not need to be included if inbound policy checking has been disabled. Keys vectors must be entered as hexadecimal or base64 numbers. They should be cryptographically strong random numbers. All hexadecimal numbers are entered as strings of hexadecimal digits (0-9 and a-f), without spaces, preceded by '0x', where each hexadecimal digit represents 4 bits. All base64 numbers are entered as strings of base64 digits (0-9, A-Z, a-z, '+' and '/'), without spaces, preceded by '0s', where each hexadecimal digit represents 6 bits and '=' is used for padding. The deletion of an SA which has been grouped will result in the entire chain being deleted. The form with no additional arguments lists the contents of /proc/net/ipsec_spi. The format of /proc/net/ipsec_spi is discussed in ipsec_spi(5). The lifetime severity of soft sets a limit when the key management daemons are asked to rekey the SA. The lifetime severity of hard sets a limit when the SA must expire. The lifetime type allocations tells the system when to expire the SA because it is being shared by too many eroutes (not currently used). The lifetime type of bytes tells the system to expire the SA after a certain number of bytes have been processed with that SA. The lifetime type of addtime tells the system to expire the SA a certain number of seconds after the SA was installed. The lifetime type of usetime tells the system to expire the SA a certain number of seconds after that SA has processed its first packet. The lifetime type of packets tells the system to expire the SA after a certain number of packets have been processed with that SA. OPTIONS
--af specifies the address family (inet for IPv4, inet6 for IPv6) --edst specifies the effective destination daddr of the Security Association --spi specifies the Security Parameters Index spi of the Security Association --proto specifies the IP protocol proto of the Security Association --said specifies the Security Association in monolithic format --ah add an SA for an IPSEC Authentication Header, specified by the following transform identifier (hmac-md5-96 or hmac-sha1-96) (RFC2402, obsoletes RFC1826) hmac-md5-96 transform following the HMAC and MD5 standards, using a 128-bit key to produce a 96-bit authenticator (RFC2403) hmac-sha1-96 transform following the HMAC and SHA1 standards, using a 160-bit key to produce a 96-bit authenticator (RFC2404) --esp add an SA for an IPSEC Encapsulation Security Payload, specified by the following transform identifier (3des, or 3des-md5-96 (RFC2406, obsoletes RFC1827) 3des encryption transform following the Triple-DES standard in Cipher-Block-Chaining mode using a 64-bit iv (internally generated) and a 192-bit 3DES ekey (RFC2451) 3des-md5-96 encryption transform following the Triple-DES standard in Cipher-Block-Chaining mode with authentication provided by HMAC and MD5 (96-bit authenticator), using a 64-bit iv (internally generated), a 192-bit 3DES ekey and a 128-bit HMAC-MD5 akey (RFC2451, RFC2403) 3des-sha1-96 encryption transform following the Triple-DES standard in Cipher-Block-Chaining mode with authentication provided by HMAC and SHA1 (96-bit authenticator), using a 64-bit iv (internally generated), a 192-bit 3DES ekey and a 160-bit HMAC-SHA1 akey (RFC2451, RFC2404) --replay_window replayw sets the replay window size; valid values are decimal, 1 to 64 --life life_param[,life_param] sets the lifetime expiry; the format of life_param consists of a comma-separated list of lifetime specifications without spaces; a lifetime specification is comprised of a severity of soft or hard followed by a '-', followed by a lifetime type of allocations, bytes, addtime, usetime or packets followed by an '=' and finally by a value --comp add an SA for IPSEC IP Compression, specified by the following transform identifier (deflate) (RFC2393) deflate compression transform following the patent-free Deflate compression algorithm (RFC2394) --ip4 add an SA for an IPv4-in-IPv4 tunnel from encap-src to encap-dst --ip6 add an SA for an IPv6-in-IPv6 tunnel from encap-src to encap-dst --src specify the source end of an IP-in-IP tunnel from encap-src to encap-dst and also specifies the source address of the Security Association to be used in inbound policy checking and must be the same address family as af and edst --dst specify the destination end of an IP-in-IP tunnel from encap-src to encap-dst --del delete the specified SA --clear clears the table of SAs --help display synopsis --version display version information EXAMPLES
To keep line lengths down and reduce clutter, some of the long keys in these examples have been abbreviated by replacing part of their text with ``...''. Keys used when the programs are actually run must, of course, be the full length required for the particular algorithm. ipsec spi --af inet --edst gw2 --spi 0x125 --proto esp --src gw1 --esp 3des-md5-96 --enckey 0x6630...97ce --authkey 0x9941...71df sets up an SA from gw1 to gw2 with an SPI of 0x125 and protocol ESP (50) using 3DES encryption with integral MD5-96 authentication transform, using an encryption key of 0x6630...97ce and an authentication key of 0x9941...71df (see note above about abbreviated keys). ipsec spi --af inet6 --edst 3049:9::9000:3100 --spi 0x150 --proto ah --src 3049:9::9000:3101 --ah hmac-md5-96 --authkey 0x1234...2eda sets up an SA from 3049:9::9000:3101 to 3049:9::9000:3100 with an SPI of 0x150 and protocol AH (50) using MD5-96 authentication transform, using an authentication key of 0x1234...2eda (see note above about abbreviated keys). ipsec spi --said tun.987@192.168.100.100 --del deletes an SA to 192.168.100.100 with an SPI of 0x987 and protocol IPv4-in-IPv4 (4). ipsec spi --said tun:500@3049:9::1000:1 --del deletes an SA to 3049:9::1000:1 with an SPI of 0x500 and protocol IPv6-in-IPv6 (4). FILES
/proc/net/ipsec_spi, /usr/local/bin/ipsec SEE ALSO
ipsec(8), ipsec_manual(8), ipsec_tncfg(8), ipsec_eroute(8), ipsec_spigrp(8), ipsec_klipsdebug(8), ipsec_spi(5) HISTORY
Written for the Linux FreeS/WAN project <http://www.freeswan.org/> by Richard Guy Briggs. BUGS
The syntax is messy and the transform naming needs work. [FIXME: source] 23 Oct 2001 IPSEC_SPI(8)
All times are GMT -4. The time now is 01:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy