transforming a multiline record to single line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting transforming a multiline record to single line
# 1  
Old 01-14-2008
transforming a multiline record to single line

Hi All
I have a file like this

<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdj
vdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>b
djvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>

How will i change the file to
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>

Please help this is urgent!!!
# 2  
Old 01-14-2008
$ cat xmltype.txt
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdj
vdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>b
djvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>

$ awk '{ if($0~/>$/) ORS="\n"; else ORS=""; print}' xmltype.txt
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>
<LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText>

//Jadu
# 3  
Old 01-14-2008
Code:
sed -n '/[>]$/p;/[^>]$/{N;s/\n//;p}' file

# 4  
Old 01-14-2008
Different syntax:


[gawk, nawk and /usr/xpg4/bin/awk on Solaris]

Code:
awk '(ORS=/<\/LText>/?"\n":"")||1' data

or:

Code:
awk '{x=x$0}/<\/LText>/{print x;x=""}' data

# 5  
Old 01-14-2008
[gawk, nawk and /usr/xpg4/bin/awk on Solaris]

Code:
awk '(ORS=/<\/LText>/?"\n":"")||1' data

or:

Code:
awk '{x=x$0}/<\/LText>/{print x;x=""}' data

[/QUOTE]

It says

awk: record `<L:RECORD><L:EPOCH>1...' too long

Is there any solution for this
# 6  
Old 01-14-2008
Quote:
Originally Posted by anju
[gawk, nawk and /usr/xpg4/bin/awk on Solaris]
[...]
It says

awk: record `<L:RECORD><L:EPOCH>1...' too long

Is there any solution for this

What OS? Solaris?
(if yes, did you try nawk?)
# 7  
Old 01-14-2008
Quote:
Originally Posted by radoulov
What OS? Solaris?
(if yes, did you try nawk?)
its unix!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combine multiline to one line till a blank line

Hello, I have a file as :- ABC DEF GHI JKL <BlankLine> MNO PQR STU VWX <BlankLine> YZA I need it as below:- ABCDEFGHIJKL; MNOPQRSTUVWX; (3 Replies)
Discussion started by: jassi10781
3 Replies

2. Shell Programming and Scripting

Print first and last line from multiline record

Hi - I'm new to working with multiline records and I'm going nuts trying to do something that seems simple. Input: Tue May 1 14:00 Header Record 1 is valid. Tue May 1 14:00 processing data to 25-Mar-2012 09:00:23.15 Tue May 1 14:03 Header Record 1 is valid. Tue May 1 14:03 processing data... (4 Replies)
Discussion started by: Catullus
4 Replies

3. Shell Programming and Scripting

Format Parts of Multiline Section to Single Line

Hello, I have an input file that I need formatted. I was hoping I could use bash to get this done. Title: Kitchen Blender Washer Dishes Title: Bathroom Toilet Sink Title: Bedroom Bed Desired output would be similar to Results("Blender","Washer","Dishes") (1 Reply)
Discussion started by: jl487
1 Replies

4. Shell Programming and Scripting

Reject the record if the record in the next line does not satisfy the pattern

Hi, I have a input file with the following entries: 1one 2two 3three 1four 2five 3six 1seven 1eight 1nine 2ten The output should be 1one 2two 3three 1four 2five 3six (2 Replies)
Discussion started by: supchand
2 Replies

5. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

6. Shell Programming and Scripting

Split a single record to multiple records & add folder name to each line

Hi Gurus, I need to cut single record in the file(asdf) to multile records based on the number of bytes..(44 characters). So every record will have 44 characters. All the records should be in the same file..to each of these lines I need to add the folder(<date>) name. I have a dir. in which... (20 Replies)
Discussion started by: ram2581
20 Replies

7. UNIX for Advanced & Expert Users

What is the difference between single line mode and multiline mode in Regular expressions?

Hi All, Can please let me know what is the difference between the single line mode and multi line mode in regular expresions? Thanks, Chidhambaram B (3 Replies)
Discussion started by: chidhu.anu
3 Replies

8. Shell Programming and Scripting

Regarding multiline record searching with specific pattern

Dear Experts, I need to extract specific records from one file which has multiline records. Input file pattern is: ============ aaaaaaaa bbbbbbbb asdf 1234 cccccccc dddddddd ============ aaaaaaaa bbbbbbbb qwer 2345 cccccccc dddddddd (7 Replies)
Discussion started by: dhiraj4mann
7 Replies

9. Shell Programming and Scripting

Multiline read with multicharacter record seperator

I have a file like the below: Start <</NumCopies 0001>> 0223 098 et(5926)sh 0223 098 mt(5926)sh End Start <</NumCopies 0001>> 0224 098 et(5926)sh 0224 098 mt(5926)sh End This file needs to be split to seperate files. Each of the seperate file will need to... (3 Replies)
Discussion started by: pt14
3 Replies

10. Shell Programming and Scripting

Awk Multiline Record Combine?

I'm trying to use Awk to get the id and name fields ($1 and $2) of file1 combined with their corresponding multiline records in file2 that are separated by blank line. Both files are ordered so that the first line of file1 corresponds to the first set of multiline records in file2 and so on. ... (4 Replies)
Discussion started by: RacerX
4 Replies
Login or Register to Ask a Question