Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Join multiple lines

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 02-22-2013
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 27 July 2015, 1:09 PM EDT
Location: The Netherlands
Posts: 7,731
Thanks: 129
Thanked 547 Times in 515 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 Unix and Linux 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 02:36 AM.