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
This User Gave Thanks to Franklin52 For This Post:
kpearson (01-19-2013)
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads 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
Delete 26 consecutive lines in a file MDeBiasse UNIX for Dummies Questions & Answers 6 05-24-2013 12:57 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 11:37 AM.

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