×
UNIX.COM Login
Username:
Password:  
Show Password






👤


UNIX Desktop Questions & Answers

Discuss UNIX and Linux user interfaces like GNOME, KDE, CDE, and Open Office here. All UNIX and Linux Newbies Welcome !!

How to concatenate consecutive lines

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-12-2009
shivi707 shivi707 is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 12 January 2009, 12:33 AM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question How to concatenate consecutive lines

I have a few lines like --

feature 1,
subfeat 0,
type 3,
subtype 1,
value 0,
--
feature 1,
subfeat 0,
type 1,
subtype 1,
value 0,

I would like to concatenate the consecutive four lines so that the output is --

feature 1,subfeat 0,type 3,subtype 1,value 0,
feature 1,subfeat 0,type 1,subtype 1,value 0,


Can anyone suggest a way to do that?
Sponsored Links
    #2  
Old 01-12-2009
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 5 June 2018, 9:29 AM EDT
Location: The Netherlands
Posts: 7,747
Thanks: 139
Thanked 558 Times in 520 Posts
Try this:



Code:
awk 'NR > 1 && /feature/{print ""}
/--/{next}
{printf $0}
END{print ""}' file

Regards
The Following User Says Thank You to Franklin52 For This Useful Post:
kpearson (01-18-2013)
Sponsored Links
👤 Login to 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
search a word and delete consecutive lines below it vikas027 Shell Programming and Scripting 3 06-03-2009 02:02 AM
need help cutting consecutive lines with sed or awk raghin Shell Programming and Scripting 2 06-04-2008 04:59 AM
grab next consecutive line or lines wisher115 Shell Programming and Scripting 1 12-07-2006 07:01 AM
Appending Consecutive lines pondlife Shell Programming and Scripting 8 08-13-2004 05:36 AM
Cutting n consecutive lines from a file... Vishnu UNIX for Dummies Questions & Answers 2 10-18-2002 10:49 AM



All times are GMT -4. The time now is 03:58 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.