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-19-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 03:29 AM
Removing 3 consecutive lines from script Grueben Shell Programming and Scripting 5 10-23-2015 12:20 PM
Eliminate consecutive lines with the same pattern sarn_nat UNIX for Dummies Questions & Answers 2 09-16-2014 01:26 PM
Matching two patterns in the consecutive lines senthil.ak UNIX for Dummies Questions & Answers 8 01-24-2014 01:26 AM
Grep couple of consecutive lines if each lines contains certain string black_fender Shell Programming and Scripting 14 05-31-2012 06:17 AM
Removing consecutive lines in a file deneuve01 Shell Programming and Scripting 11 10-06-2011 03:31 PM
Merge two non-consecutive lines munkee Shell Programming and Scripting 2 05-16-2011 06:59 PM
how to delete two consecutive lines from the file aoussenko Shell Programming and Scripting 5 04-12-2011 03:34 PM
Concatenate lines between lines starting with a specific pattern s052866 Shell Programming and Scripting 9 10-24-2010 01:09 PM
look for two consecutive lines in all text files albertkao Shell Programming and Scripting 6 09-03-2010 01:08 AM
concatenate consecutive field values polsum Shell Programming and Scripting 3 07-13-2010 10:05 PM
want to merge two consecutive lines. pank29 UNIX for Dummies Questions & Answers 6 04-25-2009 03:03 PM
grab next consecutive line or lines wisher115 Shell Programming and Scripting 1 12-07-2006 08:01 AM
Appending Consecutive lines pondlife Shell Programming and Scripting 8 08-13-2004 06:36 AM
Cutting n consecutive lines from a file... Vishnu UNIX for Dummies Questions & Answers 2 10-18-2002 11:49 AM


All times are GMT -4. The time now is 07:49 PM.

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