LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-20-2012, 03:06 AM   #1
arn2025
LQ Newbie
 
Registered: Feb 2012
Posts: 26
Blog Entries: 1

Rep: Reputation: Disabled
Manuplating text


I have a very long text file that I want to change into columns so that it is arranged as

SID PCRFINDEX SUBSCRIBERSN SUBSCRIBERIDENTIFIER
730B020246D48407 0 730B060246D48407 256310903857
730B0A02B8D48407 0 730B0E02B8D48407 256310904578



"
<SUBBEGIN
SID=730B020246D48407;
PCRFINDEX=0;
SUBSCRIBERSN=730B060246D48407;
SUBSCRIBERIDENTIFIER=256310903857;
MSISDN=310903857;
STATUS=1;
PAIDTYPE=254;
STATION=1;
CONTACTMETHOD=2;
BILLINGCYCLEDAY=26;
DOMAINNAME=default1;
DOMAINID=0000000000000063;
SPNAME=default1;
SPID=0000000000000063;
ONLINESTATUS=2;
<SUBEND
<SUBBEGIN
SID=730B0A02B8D48407;
PCRFINDEX=0;
SUBSCRIBERSN=730B0E02B8D48407;
SUBSCRIBERIDENTIFIER=256310904578;
MSISDN=310904578;
STATUS=1;
PAIDTYPE=254;
STATION=1;
CONTACTMETHOD=2;
BILLINGCYCLEDAY=26;
DOMAINNAME=default1;
DOMAINID=0000000000000063;
SPNAME=default1;
SPID=0000000000000063;
ONLINESTATUS=2;
<SUBEND
<SUBBEGIN
SID=730B120232D58407;
PCRFINDEX=0;
SUBSCRIBERSN=730B160232D58407;
SUBSCRIBERIDENTIFIER=256310901978;
MSISDN=310901978;
STATUS=1;
PAIDTYPE=254;
STATION=1;
CONTACTMETHOD=2;
BILLINGCYCLEDAY=26;
DOMAINNAME=default1;
DOMAINID=0000000000000063;
SPNAME=default1;
SPID=0000000000000063;
ONLINESTATUS=2;
<SUBEND
 
Old 03-20-2012, 03:23 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Is this what you are looking for:
Code:
awk 'BEGIN { RS="<SUBBEGIN" ; FS = "\n" } { gsub(/([A-Z]+=|;)/,"",$0 ) ; print $2, $3, $4, $5 }' infile
Sample run with the data given in post #1:
Code:
$ awk 'BEGIN { RS="<SUBBEGIN" ; FS = "\n" } { gsub(/([A-Z]+=|;)/,"",$0 ) ; print $2, $3, $4, $5 }' infile
730B020246D48407 0 730B060246D48407 256310903857
730B0A02B8D48407 0 730B0E02B8D48407 256310904578
730B120232D58407 0 730B160232D58407 256310901978
Hope this helps.
 
1 members found this post helpful.
Old 03-20-2012, 06:08 AM   #3
arn2025
LQ Newbie
 
Registered: Feb 2012
Posts: 26

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Thanks, this really worked
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash command to 'cut' text into another text file & modifying text. velgasius Programming 4 10-17-2011 04:55 AM
LXer: Listen to Text and Instant Messages with Gespeaker 'Text To Speech' Utility LXer Syndicated Linux News 0 09-25-2010 08:11 PM
How to parse text file to a set text column width and output to new text file? jsstevenson Programming 12 04-23-2008 02:36 PM
Steps needed to convert multiple text files into one master text file jamtech Programming 5 10-07-2007 11:24 PM
in Pascal: how to exec a program, discard text output or send to text file Valkyrie_of_valhalla Programming 6 05-02-2007 09:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration