The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
make multiple line containing a pattern into single line VTAWKVT Shell Programming and Scripting 13 15 Hours Ago 03:40 PM
AWK - if last line/record do something PacificWonder Shell Programming and Scripting 3 06-05-2008 08:13 PM
Multi-line output to single line LinuxRacr Shell Programming and Scripting 7 02-26-2008 07:05 AM
Create two line from single line in shell unishiva Shell Programming and Scripting 2 11-02-2007 09:28 PM
how to extract last line in record bjorb Shell Programming and Scripting 7 10-17-2005 11:12 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-14-2008
Registered User
 

Join Date: Jan 2008
Location: Bangalore
Posts: 17
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!!!
Reply With Quote
Forum Sponsor
  #2  
Old 01-14-2008
jaduks's Avatar
Registered User
 

Join Date: Aug 2007
Location: Assam,India
Posts: 146
$ 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
Reply With Quote
  #3  
Old 01-14-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Code:
sed -n '/[>]$/p;/[^>]$/{N;s/\n//;p}' file
Reply With Quote
  #4  
Old 01-14-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,933
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
Reply With Quote
  #5  
Old 01-14-2008
Registered User
 

Join Date: Jan 2008
Location: Bangalore
Posts: 17
[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
Reply With Quote
  #6  
Old 01-14-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,933
Quote:
Originally Posted by anju View Post
[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?)
Reply With Quote
  #7  
Old 01-14-2008
Registered User
 

Join Date: Jan 2008
Location: Bangalore
Posts: 17
Quote:
Originally Posted by radoulov View Post
What OS? Solaris?
(if yes, did you try nawk?)
its unix!!!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0