Join multiple lines | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

Join multiple lines

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-22-2013
hench hench is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 8 May 2013, 7:14 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Join multiple lines

Hi

I have a source file ( written i C ) where a funtion call is spread over multiple lines, for example :

func(
a,
b,
c
);

I want this to be joined into one single line :

func(a,b,c);

How can this be done with awk and sed ?

Regards. Hench
Sponsored Links
    #2  
Old 02-22-2013
Franklin52's Avatar
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 25 November 2014, 4:53 AM EST
Location: The Netherlands
Posts: 7,720
Thanks: 123
Thanked 538 Times in 508 Posts
Maybe you can try something like this:

Code:
awk '/);/{c=0} /func\(/{c=1} c{printf $0;next}1' file > newfile

Sponsored Links
    #3  
Old 02-22-2013
hench hench is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 8 May 2013, 7:14 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Franklin52 !
It works fine.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to use the the join command to join multiple files by a common column evelibertine UNIX for Dummies Questions & Answers 5 07-05-2012 05:15 PM
How to use SED to join multiple lines? DrivesMeCrazy Shell Programming and Scripting 12 12-21-2009 12:24 PM
Join 2 files with multiple columns: awk/grep/join? InfoSeeker UNIX for Dummies Questions & Answers 3 12-01-2009 08:45 PM
join on a file with multiple lines, fields crimper Shell Programming and Scripting 5 12-15-2008 04:50 AM
Awk Join multiple lines hitmansilentass Shell Programming and Scripting 5 10-27-2006 12:04 PM



All times are GMT -4. The time now is 04:44 PM.