Home Man
Search
Today's Posts
Register

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

Tags
desktop, line, lines

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 01-12-2009
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?
# 2  
Old 01-12-2009
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)
Login to Reply

« Previous Thread | Next 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
Grep three consecutive lines if each lines contains certain string Saumitra Pandey Shell Programming and Scripting 7 11-20-2015 02:29 AM
Removing 3 consecutive lines from script Grueben Shell Programming and Scripting 5 10-23-2015 11:20 AM
Eliminate consecutive lines with the same pattern sarn_nat UNIX for Dummies Questions & Answers 2 09-16-2014 12:26 PM
Grep couple of consecutive lines if each lines contains certain string black_fender Shell Programming and Scripting 14 05-31-2012 05:17 AM
Merge two non-consecutive lines munkee Shell Programming and Scripting 2 05-16-2011 05:59 PM
Concatenate lines between lines starting with a specific pattern s052866 Shell Programming and Scripting 9 10-24-2010 12:09 PM
concatenate consecutive field values polsum Shell Programming and Scripting 3 07-13-2010 09:05 PM
want to merge two consecutive lines. pank29 UNIX for Dummies Questions & Answers 6 04-25-2009 02:03 PM
need help cutting consecutive lines with sed or awk raghin Shell Programming and Scripting 2 06-04-2008 04:59 AM
Appending Consecutive lines pondlife Shell Programming and Scripting 8 08-13-2004 05:36 AM


All times are GMT -4. The time now is 06:21 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password