How to concatenate consecutive lines


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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  
Try this:

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

Regards
This User Gave Thanks to Franklin52 For This Post:
Login or Register to Reply

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

More UNIX and Linux Forum Topics You Might Find Helpful
Grep three consecutive lines if each lines contains certain string
Saumitra Pandey
say we have : 2914 | REQUEST | whatever 2914 | RESPONSE | whatever 2914 | SUCCESS | whatever 2985 | RESPONSE | whatever 2986 | REQUEST | whatever 2990 | REQUEST | whatever 2985 | RESPONSE | whatever 2996 | REQUEST | whatever 2010 | SUCCESS | whatever 2013 | REQUEST | whatever 2013 |...... Shell Programming and Scripting
7
Shell Programming and Scripting
Grep couple of consecutive lines if each lines contains certain string
black_fender
Hello, I want to extract from a file like : 20120530025502914 | REQUEST | whatever 20120530025502968 | RESPONSE | whatever 20120530025502985 | RESPONSE | whatever 20120530025502996 | REQUEST | whatever 20120530025503013 | REQUEST | whatever 20120530025503045 | RESPONSE | whatever I want...... Shell Programming and Scripting
14
Shell Programming and Scripting
Concatenate lines between lines starting with a specific pattern
s052866
Hi, I have a file such as: --- >contig00001 length=35524 numreads=2944 gACGCCGCGCGCCGCGGCCAGGGCTGGCCCA CAGGCCGCGCGGCGTCGGCTGGCTGAG >contig00002 length=4242 numreads=43423 ATGCCGAAGGTCCGCCTGGGGCTGG CGCCGGGAGCATGTAGCG --- I would like to concatenate the lines not starting with ">"...... Shell Programming and Scripting
9
Shell Programming and Scripting
concatenate consecutive field values
polsum
Hi, I have a file like this A Bob A Sam A John B David C Paul C Sandra If the consecutive field values in column one is same, then concatenate the corresponding strings. So, I need an output like this, A Bob_Sam_John B David C Paul_Sandra I usually work with excel but...... Shell Programming and Scripting
3
Shell Programming and Scripting
want to merge two consecutive lines.
pank29
Hi All, I want to merge two consecutive lines. Currently the output is :--> crmplp1 cmis461 No Online cmis462 No Offline crmplp2 cmis462 No Online cmis463 No ...... UNIX for Dummies Questions & Answers
6
UNIX for Dummies Questions & Answers