Sponsored Content
Top Forums Shell Programming and Scripting Parsing a txt file according to two different tags Post 302936123 by snr_silencer on Monday 23rd of February 2015 07:10:29 AM
Old 02-23-2015
Parsing a txt file according to two different tags

I need to parse a txt file like below.

starts from the first occurence of
SASN2010Aber.CallEventRecord.egsnPDPRecord
{

till the last occurence of
}


in other saying name of the part(header) is SASN2010Aber.CallEventRecord.egsnPDPRecord and the content of the header is in two parenthesis {}, untill the next header.

How can I parse and separate these headers including content?

text file is below;
Code:
SASN2010Aber.CallEventRecord.egsnPDPRecord
{
    recordType : '70'D
    chargingID : '306457009'D
    sgsnAddress
    {
        Address : 'FBDC'H
    }
    pdpType : 'F121'H
    dynamicAddressFlag : '1'D
    listOfTrafficVolumes
    {
        [0]
        {
            changeTime : '1412031353342B0200'H
        }
    }
    duration : '0'D
    causeForRecClosing : '0'D
    recordSequenceNumber : '1'D
    rATType : '1'D
    listOfServiceData
    {
        [0]
        {
            ratingGroup : '4'D
            resultCode : '4010'D
            timeUsage : '0'D
            timeOfReport : '1412031353342B0200'H
            failureHandlingContinue : '0'D
            serviceIdentifier : '404'D
        }
    }
}

SASN2010Aber.CallEventRecord.egsnPDPRecord
{
    recordType : '70'D
    chargingID : '306457009'D
    sgsnAddress
    {
        Address : 'FBDC'H
    }
    pdpType : 'F121'H
    dynamicAddressFlag : '1'D
    listOfTrafficVolumes
    {
        [0]
        {
            changeTime : '1412031353342B0200'H
        }
    }
    causeForRecClosing : '0'D
    rATType : '1'D
    listOfServiceData
    {
        [0]
        {
            ratingGroup : '4'D
            resultCode : '4010'D
            failureHandlingContinue : '0'D
            serviceIdentifier : '404'D
        }
        [1]
        {
            ratingGroup : '4'D
            resultCode : '4010'D
            failureHandlingContinue : '0'D
            serviceIdentifier : '404'D
        }

    }
}

SASN2010Aber.CallEventRecord.egsnPDPRecord
{
    sgsnAddress
    {
        Address : 'FBDC'H
    }
    pdpType : 'F121'H
    listOfTrafficVolumes
    {
        [0]
        {
            changeTime : '1412031353342B0200'H
        }
    }
    duration : '0'D
    listOfServiceData
    {
        [3]
        {
            ratingGroup : '4'D
            resultCode : '4010'D
            timeUsage : '0'D
            serviceIdentifier : '404'D
        }
    }
}

the output need to be like below (3 divided);
Code:
SASN2010Aber.CallEventRecord.egsnPDPRecord
{
.
.
.
.
.
.
}

Code:
SASN2010Aber.CallEventRecord.egsnPDPRecord
{
.
.
.
.
.
.
}

Code:
SASN2010Aber.CallEventRecord.egsnPDPRecord
{
.
.
.
.
.
.
}


Last edited by snr_silencer; 02-23-2015 at 09:20 AM.. Reason: Added ICODE tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies

2. Shell Programming and Scripting

command to list .txt and .TXT file

Hi expersts, in my directory i have *.txt and *.TXT and *.TXT.log, *.txt.log I want list only .txt and .TXT files in one command... how to ?? //purple (1 Reply)
Discussion started by: thepurple
1 Replies

3. Shell Programming and Scripting

help parsing txt with awk

Hi all I would need some help to introduce 'break' lines into the following data by using awk: original data: RECORD 1000 aaa xxxxxx RECORD 1001 aaa xxxxxx RECORD 1002 bbb xxxxxx RECORD 1003 bbb xxxxxx RECORD 1004 bbb xxxxxx RECORD 1005 ccc xxxxxx RECORD 1006 ccc xxxxxx RECORD 1007... (5 Replies)
Discussion started by: yomaya
5 Replies

4. Shell Programming and Scripting

parsing txt file, saving graphics files

hi everyone, i am a newbie in shell programming. and i want to simply go through a text file that contains 3 "columns", split by ';' customerID ; link-to-contract ; save-as-filename so an example would simply look like this now i want to loop through every line, and save the file from... (3 Replies)
Discussion started by: Confidence
3 Replies

5. Shell Programming and Scripting

Parsing txt, xml files and preparing csv file

Hi, I need to parse text, xml files to get the statistic numbers and prepare summary csv file. What is the best way to parse these file and prepare csv file. Any idea you have , please? Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies

6. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

7. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

8. Shell Programming and Scripting

XML Parsing having optional tags into flat file

In xml file i have following data where some tags like<ChrgBr> may not be present in every next file. So i want these values to be stored in some variable like var1="405360,00" , var2="DEBT" and so on ,but if <ChrgBr> tag has no value or is absent var2 should have space like var2=" " so that i... (1 Reply)
Discussion started by: sandipgawale
1 Replies

9. Windows & DOS: Issues & Discussions

Parsing a UNIX txt to separate files

I have a requirement to parse a dataflex .txt file and break it into separate files within the Windows server env. Is there any special characters I should pay particular attention on the unix side? Any ideas? Thanks in advance (2 Replies)
Discussion started by: kicklinr
2 Replies

10. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies
All times are GMT -4. The time now is 04:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy