Sponsored Content
Top Forums Shell Programming and Scripting Use sed to merge multiple lines Post 302083721 by System Shock on Monday 7th of August 2006 11:46:55 PM
Old 08-08-2006
Well, gets kind of tricky because of the arbitrary number of lines between "test" and "world", plus the arbitrary number of ines between "world" and "test"...
.,.. someone smarter than me will probably give you a better answer, but this works Smilie
Code:
 sed 's/$/ @/' file.txt | sed -n '/test/,/world/p' | sed '/world/G' | sed -e :a -e '/@$/N; s/\@\n//; ta'


Last edited by System Shock; 08-08-2006 at 12:57 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

merge multiple lines from flat file

Hi, I have a tab delimited flat file like this: 189 Guide de lutilisateur sur lappel conférence à trois au moyen d'adaptateurs téléphoniques <TABLE><TBODY><TR><TD><DIV class=subheader>La fonction Appel conférence à trois </DIV></TD> \ <TD><?php print $navTree;?> vous permet de tenir un appel... (4 Replies)
Discussion started by: hnhegde
4 Replies

2. Shell Programming and Scripting

Removing end of line to merge multiple lines

I'm sure this will be an easy question for you experts out there, but I have been searching the forum and working on this for a couple hours now and can't get it right. I have a very messy data file that I am trying to tidy up - one of the issues is some records are split into multiple lines: ... (4 Replies)
Discussion started by: tink
4 Replies

3. Shell Programming and Scripting

Using Perl to Merge Multiple Lines in a File

I've hunted and hunted but nothing seems to apply to what I need. Any help will be much appreciated! My input file looks like (Unix): marker,allele1,allele2 RS1002244,1,1 RS1002244,1,3 RS1002244,3,3 RS1003719,2,2 RS1003719,2,4 RS1003719,4,4 Most markers are listed 3 times but a few... (2 Replies)
Discussion started by: Peggy White
2 Replies

4. Shell Programming and Scripting

Merge two lines using sed

Hi, I am trying to merge two lines, first line starts with a particular pattern and second line ends with a particular pattern in a file. Something like: First line starts with say ABC Second line ends with say XYZ After a merge, the line should become ABC.......XYZ I tried... (14 Replies)
Discussion started by: Sunny Arora
14 Replies

5. Shell Programming and Scripting

Sed - merge lines bw 2 specific characters

Hi, I have a bash script and I am looking for a command that will merge specific lines together. Sample Data: registration time = 1300890272 Id = 1 setd = 0 tagunt = 26 tagId=6, length=8, value= tagId=9, length=5, value= tagId=7, length=2, value= tagId=16, length=2, value= tagId=32,... (8 Replies)
Discussion started by: Winsarc
8 Replies

6. Shell Programming and Scripting

Merge multiple lines in same file with common key using awk

I've been a Unix admin for nearly 30 years and never learned AWK. I've seen several similar posts here, but haven't been able to adapt the answers to my situation. AWK is so damn cryptic! ;) I have a single file with ~900 lines (CSV list). Each line starts with an ID, but with different stuff... (6 Replies)
Discussion started by: protosd
6 Replies

7. Shell Programming and Scripting

Merge multiple lines in one line

Hi guys, So i have a input file with several sequences aligned (fasta) >NC_005930 241 bp MNMINIFIINNIFDQFIPVKLSIFSLTSVGSIIA LSWVWINTKTHWAISRSNTP-SLLLNSL WTLLITNL-NEKTNPWAPWLFSLFLLCFSFNIMSLI-PYTF-SQ TSHLSFTFGLSLPIWIMVNIAGFKNNWKKKISHLLPQGTPIYLVPVMII IETISLFIQPLTLGFRLGANLLAGHLLIFLCSCTIWE... (6 Replies)
Discussion started by: andreia
6 Replies

8. UNIX for Dummies Questions & Answers

Need help combining txt files w/ multiple lines into csv single cell - also need data merge

:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux. I am working in Linux terminal. I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies

9. Shell Programming and Scripting

Sed: how to merge two lines moving matched pattern to end of previous line

hello everyone, im new here, and also programming with awk, sed and grep commands on linux. In my text i have many lines with this config: 1 1 4 3 1 1 2 5 2 2 1 1 1 3 1 2 1 3 1 1 1 2 2 2 5 2 4 1 3 2 1 1 4 1 2 1 1 1 3 2 1 1 5 4 1 3 1 1... (3 Replies)
Discussion started by: satir
3 Replies

10. Shell Programming and Scripting

Merge multiple lines into a single line

Hi all, I'm relatively new to scripting, I can do pretty basic things. I have a daily log file that looks like: timestamp=2017-06-28-01.01.35.080576; event status=0; userid=user1; authid=user1; application id=10.10.10.10.11111.12345678901; application name=GUI; ... (29 Replies)
Discussion started by: dwdnet
29 Replies
SUBSCRIPTIONS(5)					    InterNetNews Documentation						  SUBSCRIPTIONS(5)

NAME
subscriptions - Default recommended subscriptions DESCRIPTION
The pathetc/subscriptions file contains a list of newsgroups that is returned by the NNTP command LIST SUBSCRIPTIONS. Clients that support this command usually send it the first time they connect to a new news server. They use the returned list to initialize the list of subscribed newsgroups. The subscriptions file therefore should contain groups intended for new users, for testing, or that contain FAQs and other useful information for first-time Usenet users. The syntax of the subscriptions file is trivial; it is a simple list of newsgroup names, one per line. The order of newsgroups may be significant; the news reading client may present the groups in that order to the user. Be aware that use of the LIST SUBSCRIPTIONS command is not widespread (though documented in RFC 6048) and most news clients will never ask for this file. EXAMPLE
A typical subscriptions file may look like: news.announce.newusers news.newusers.questions local.test local.general local.talk misc.test misc.test.moderated news.answers news.announce.newgroups This gives the client the FAQs and question newsgroup for new users first, then a local newsgroup for testing and various commonly-read local discussion groups, followed by the world-wide test groups, all the FAQs, and announcements of new world-wide newsgroups. If there is a local new users group, one might want to list it first. HISTORY
Written by Bettina Fink <laura@hydrophil.de> for InterNetNews. $Id: subscriptions.pod 9138 2010-10-29 18:09:50Z iulius $ SEE ALSO
nnrpd(8). INN 2.5.3 2011-06-10 SUBSCRIPTIONS(5)
All times are GMT -4. The time now is 10:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy