Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Join multiple lines

Shell Programming and Scripting


Closed    
 
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: 18 October 2016, 9:44 AM EDT
Posts: 4
Thanks: 1
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: 6 December 2016, 6:40 AM EST
Location: The Netherlands
Posts: 7,746
Thanks: 139
Thanked 558 Times in 520 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: 18 October 2016, 9:44 AM EDT
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks Franklin52 !
It works fine.
Sponsored Links
Closed

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 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 03:50 AM.