How to concatenate lines with specific pattern?
I have data dumped from a table into text file. In some occurrence the data row is split into two rows.
Example:
Expected Result:
In the example above. Line #4 and #5 is one data row. The text file has about 300K+ rows.
Basically concatenate the current line with the next line if the next line starts with '|'.
The suggestion made by Bartus11 worked as expected. Updated the exact expected rows.
The suggestion made by Yoda worked, but updated about 2K additional rows.
I'm not perl and awk expert. Can you please provide some more detail on what exactly is happening with the command provided? This would help me learn.
thank you
---------- Post updated at 03:34 PM ---------- Previous update was at 03:34 PM ----------
I have gained some understanding on the code provided by Bartus11
But, how do I go about changing this to work where the next continued line has '|' as 2nd character instead of 1st.
Example:
Result:
As per the suggestion using Perl, I could do that following:
This will work if I put them in a loop, but probably not the smartest way to do it.
Any suggestions?
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)
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)
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)
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)
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)
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)
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)
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)
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)