Sponsored Content
Top Forums Shell Programming and Scripting How to concatenate lines with specific pattern? Post 302826039 by nixtime on Tuesday 25th of June 2013 05:23:07 PM
Old 06-25-2013
Hi RudiC,

It concatenates even if the next line does not have a '|'.

Test data
Code:
12345671|abcd|0
|123456789
12345672|abcd|0
1|23456789
12345673|abcd|0
12|3456789
12345674|abcd|0
123|456789
12345675|abcd|0
1234|56789
12345676|abcd|0
12345|6789
12345677|abcd|0
123456|789
12345678|abcd|0
1234567|89
12345679|abcd|0
12345678|9
12345670|abcd|0
123456789|
12345670|abcd|0
123456789A

Result:
Code:
12345671|abcd|0|123456789
12345672|abcd|01|23456789
12345673|abcd|012|3456789
12345674|abcd|0123|456789
12345675|abcd|01234|56789
12345676|abcd|012345|6789
12345677|abcd|0123456|789
12345678|abcd|01234567|89
12345679|abcd|012345678|9
12345670|abcd|0123456789|
12345670|abcd|0123456789A

Though it is not clearly specified in my initial post.. A line is a genuine new line if the 1st occurence of '|' is the 9th character. Rest of lines would be continuation of the prior line, which I wanted to concatenate.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenate lines between lines starting with a specific pattern

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 ">"... (9 Replies)
Discussion started by: s052866
9 Replies

2. Shell Programming and Scripting

how to delete lines from a file which starts with a specific pattern

I need to delete those lines from a file, which starts with 45. How to do it? (3 Replies)
Discussion started by: mady135
3 Replies

3. Shell Programming and Scripting

merging of 2 consecutive lines in a file for a specific pattern

Hi , I'm looking for a way to merge two lines only for a given pattern / condition. Input : abcd/dad + -49.201 2.09 -49.5 34 ewrew rewtre * fdsgfds/dsgf/sdfdsfasdd + -4.30 0.62 -49.5 45 sdfdsf cvbbv * sdfds/retret/asdsaddsa + ... (1 Reply)
Discussion started by: novice_man
1 Replies

4. Shell Programming and Scripting

NAWK to remove lines that matches a specific pattern

Hi, I have requirement that I need to split my input file into two files based on a search pattern "abc" For eg. my input file has below content abc defgh zyx I need file 1 with abc and file2 with defgh zyx I can use grep command to acheive this. But with grep I need... (8 Replies)
Discussion started by: sbhuvana20
8 Replies

5. Shell Programming and Scripting

Delete multiple lines starting with a specific pattern

Hi, just tried some script, awk, sed for the last 2 hours and now need help. Let's say I have a huge file of 800,000 lines like this : It's a tedious job to look through it, I'd like to remove those useless lines in it as there's a few thousands : Or to be even more precise : if line1 =... (6 Replies)
Discussion started by: Zurd
6 Replies

6. Shell Programming and Scripting

Append lines for a specific pattern

Input: 09:43:46,538 INFO first text 10:45:46,538 INFO second text 11:00:46,538 INFO third more text Output: 09:43:46,538 INFO first text 10:45:46,538 INFO second text 11:00:46,538 INFO third more text The rule is to append all lines so each line contains this format... (7 Replies)
Discussion started by: chitech
7 Replies

7. Shell Programming and Scripting

Want to get lines before specific pattern

Hi , I want to insert data into a new file after grepping specific pattern . for more info please read following for example: abc=12345678902222 def=45678904444 ------- ------- INAVLID ABC I want to "INAVLID ABC" grep above pattern from multiple files and want to write abc value and ... (3 Replies)
Discussion started by: vipin auja
3 Replies

8. Shell Programming and Scripting

Vi editor deleting lines with specific pattern

Hi, I need to delete all lines in the file using vi editor which start with word aternqaco. Please assist. aternqaco.__oracle_base='/amdbqa01/app/oracle'#ORACLE_BASE set from environment aternqa.__oracle_base='/amdbqa01/app/oracle'#ORACLE_BASE set from environment... (3 Replies)
Discussion started by: Vishal_dba
3 Replies

9. Shell Programming and Scripting

Delete lines that contain a pattern from specific line to the end.

Gents, I am trying to delete all lines which start with "H" character, but keeping the fist header. Example In the input file I will delete all lines starting from line 8 which contents character "H" to the end of the file. I try sed '8,10000{/^H/d;}' file But as don't know the end... (1 Reply)
Discussion started by: jiam912
1 Replies

10. Shell Programming and Scripting

Print all lines between two keyword if a specific pattern exist

I have input file as below I need to check for a pattern and if it is there in file then I need to print all the lines below BEGIN and END keyword. Could you please help me how to get this in AIX using sed or awk. Input file: ABC ******** BEGIN ***** My name is Amit. I am learning unix.... (8 Replies)
Discussion started by: Amit Joshi
8 Replies
BacklightdTester(1)					    BSD General Commands Manual 				       BacklightdTester(1)

NAME
BacklightdTester, Other_name_for_same_program(), Yet another name for the same program. -- This line parsed for whatis database. SYNOPSIS
BacklightdTester, [-abcd] [-a path] [file] [file ...] arg0 arg2 ... DESCRIPTION
Use the .Nm macro to refer to your program throughout the man page like such: BacklightdTester, Underlining is accomplished with the .Ar macro like this: underlined text. A list of items with descriptions: item a Description of item a item b Description of item b A list of flags and their descriptions: -a Description of -a flag -b Description of -b flag FILES
/usr/share/file_name FILE_1 description /Users/joeuser/Library/really_long_file_name FILE_2 description SEE ALSO
a(1), b(1), c(1), a(2), b(2), a(3), b(3) Darwin May 31, 2019 Darwin
All times are GMT -4. The time now is 09:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy