The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multiline replace problem mathis Shell Programming and Scripting 2 02-13-2009 12:46 PM
how to display multiline text mmunir Shell Programming and Scripting 2 02-05-2009 03:56 PM
Awk Multiline Record Combine? RacerX Shell Programming and Scripting 4 10-28-2008 01:27 AM
How to merge multiline into line begining with specific word missyou Shell Programming and Scripting 2 10-14-2008 06:35 AM
Multiline Grep tolmark UNIX for Dummies Questions & Answers 4 03-14-2008 12:31 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-11-2009
inteliduy inteliduy is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 2
Merge multiline into Singleline

Hi,

I'm newbie in this forum and I already searched regarding Merge multiline into singleline but I always found different result which is I don't want it like i want.

Here is the data that i have it:
*** ALARM 711 A1/BTS "MAD08B1 08ACPA0"U 090604 1040
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT

MO RSITE CLASS
RXOCF-59 MD2026 1

EXTERNAL ALARM
TEMPERATURA ALTA
AIRE CONDICIONA
*** ALARM 710 A1/BTS "MAD08B1 08ACPA0"U 090604 1040
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT

MO RSITE CLASS
RXOCF-97 MD2059 1

EXTERNAL ALARM
FUEGO
TEMPERATURA BAJA

And the output I would likes belows:
*** ALARM 711 A1/BTS "MAD08B1 08ACPA0"U 090604 1040 RADIO X-CEIVER ADMINISTRATION BTS EXTERNAL FAULT MO RSITE CLASS RXOCF-59 MD2026 1 EXTERNAL ALARM TEMPERATURA ALTA AIRE CONDICIONA
*** ALARM 710 A1/BTS "MAD08B1 08ACPA0"U 090604 1040 RADIO X-CEIVER ADMINISTRATION BTS EXTERNAL FAULT MO RSITE CLASS RXOCF-97 MD2059 1 EXTERNAL ALARM FUEGO TEMPERATURA ALTA


Is there any csh or Perl scripts to make it?

Thank you for your help.
Inteliduy
  #2 (permalink)  
Old 06-11-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
This assumes your block of text always starts with * * *
Code:
awk ' {if(length(old)>0 && index("* * *", $0) > 0) 
            {print old; old=$0; next}
        old=old $0 
        } 
        END{ print old} ' logfile > newfile
  #3 (permalink)  
Old 06-11-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,540
if you have Python
Code:
#!/usr/bin/env python
data=[i for i in open("file").read().split("***") if i != ""]
for item in data:
    print "***" + item.replace("\n","").strip()
output
Code:
# ./test.py
***ALARM 711 A1/BTS "MAD08B1 08ACPA0"U 090604 1040RADIO X-CEIVER ADMINISTRATIONBTS EXTERNAL FAULTMO RSITE CLASSRXOCF-59 MD2026 1EXTERNAL ALARMTEMPERATURA ALTAAIRE CONDICIONA
***ALARM 710 A1/BTS "MAD08B1 08ACPA0"U 090604 1040RADIO X-CEIVER ADMINISTRATIONBTS EXTERNAL FAULTMO RSITE CLASSRXOCF-97 MD2059 1EXTERNAL ALARMFUEGOTEMPERATURA BAJA
  #4 (permalink)  
Old 06-12-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,088
Code:
while(<DATA>){
	chomp;
	if (/\*{3}/ && $.!=1){
		print "\n";
	}
	print $_," ";
}
__DATA__
*** ALARM 711 A1/BTS "MAD08B1 08ACPA0"U 090604 1040
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT

MO RSITE CLASS
RXOCF-59 MD2026 1

EXTERNAL ALARM
TEMPERATURA ALTA
AIRE CONDICIONA 
*** ALARM 710 A1/BTS "MAD08B1 08ACPA0"U 090604 1040
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT

MO RSITE CLASS
RXOCF-97 MD2059 1

EXTERNAL ALARM
FUEGO
TEMPERATURA BAJA
  #5 (permalink)  
Old 06-12-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
Code:
 
cat inputfile.txt | tr "\n" " " | awk '{ print $0"\n" }' | sed 's/ \*\*\*/\
\*\*\*/g'
  #6 (permalink)  
Old 06-15-2009
inteliduy inteliduy is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 2
All,

Thank you for your help and I will try it. I will let you know.

Thanks a lot,
Inteliduy
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0