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


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

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-22-2013
Registered User
 
Join Date: Dec 2008
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
Moderator
 
Join Date: Feb 2007
Location: The Netherlands
Posts: 7,500
Thanks: 73
Thanked 473 Times in 452 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
Registered User
 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Franklin52 !
It works fine.
Sponsored Links
Reply

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 04:15 PM
How to use SED to join multiple lines? DrivesMeCrazy Shell Programming and Scripting 12 12-21-2009 11:24 AM
Join 2 files with multiple columns: awk/grep/join? InfoSeeker UNIX for Dummies Questions & Answers 3 12-01-2009 07:45 PM
join on a file with multiple lines, fields crimper Shell Programming and Scripting 5 12-15-2008 03:50 AM
Awk Join multiple lines hitmansilentass Shell Programming and Scripting 5 10-27-2006 11:04 AM



All times are GMT -4. The time now is 09:26 PM.