Extracting text between two strings, multiple instances
Hi experts,
Ive got a text file which has the following text which will occur in this format at least one time:
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajcqsqdqwdqad
<<=========================+
It is likely that this will occur numerous times in a file which shouldn't have more than 200 lines.
The text between >> and << is what I want to extract to a different file.
The following code will grab it but only the first instance:
How can I get this to loop through to EOF?
Thanks for the code - It does 90% of what I want:
The text it is lanalysing looks like this:
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajc
<<=========================+
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajcqsqdqwdqad
<<=========================+
And the output is:
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajc
<<=========================+
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajcqsqdqwdqad
How can I get it to output only the text between the ">>" and "<<" strings?
Hi Martin
When I run the sed command with your input file, it gives what is expected. 90% means what? Please clearly state what you are getting right now, and how did you expect the output to appear?
Hi Guru, as in my above post the text I am looking through looks like the following:
Quote:
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajc
<<=========================+
Some other info
some other info
I dont want this
I dont want this either
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajcqsqdqwdqad
<<=========================+
And the command is currently outputting the following:
Quote:
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajc
<<=========================+
+=========================>>
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajcqsqdqwdqad
Ideally I would want to output just the following:
Quote:
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajc
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajcqsqdqwdqad
Thanks a bunch works great!
Now to try an make it even better (not a necessity)...
Is there a way to put a line space between each output of the instance?
I'm currently getting:
Quote:
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajc
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajcqsqdqwdqad
Would it be possible to get the output to look like:
Quote:
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajc
Some stuff that evreryone should knnow
other stufsjdokajkajokajda
aijhjajcdjajcisajcqsqdqwdqad
I know I'm asking alot and I really appreciate it!
Thx
M
Last edited by martin0852; 10-12-2012 at 03:30 AM..
Hi Team -
I hope everyone has been well!
I export a file from one of our source systems that gives me more information than I need. The way the file outputs, I need to extract certain strings at different positions on the file and echo them to another file.
I can do this in batch easily,... (2 Replies)
I need to get text between two strings <app-deployment file=" and </app-deployment> as it appears more than once in the file then how can i store the text between each occurrence in a separate file ?
Thus, i need the below to go in found1.tmp
and the below to go in found2.tmp
... (8 Replies)
Dear All,
I have to solve the following problems with multiple tab-separated text file but I don't know how. Any help would be greatly appreciated. I have access to Linux mint (but not as a professional).
I have multiple tab-delimited files with the following structure:
file1:
1 44
2 ... (5 Replies)
Here is my task, I feel sure this can be accomplished with see/awk but can't seem to figure out how.
I have large flat file from which I need to extract every case of a pairing of characters (GG) in this case PLUS the previous 20 characters. The output should be a list (which I plan to make... (17 Replies)
Hello. I am sorry if this is a common question but through all my searching, I haven't found an answer which matches what I want to do.
I am looking for a sed command that will parse through a large text file and extract lines that start with specific words (which are repeated throughout the... (4 Replies)
Hi All,
I have a file whose common patter is like this:
.I 1
.U
87049087
.S
Some text here too
.M
This is a text
.T
Some another text here
.P
Name of the book
.W
Some lines of more text. This text needs to be extracted.
.A
more text goes here too
.I 2 (2 Replies)
Hello. This shouldn't be an unusual problem, but I cannot find anything about it at google or at other search machine.
So, I've made an application using C++ and QtCreator. I 've made a new mime type for application's project files.
My system (ubuntu 10.10), when I right click a file and I... (3 Replies)
Hi,
I've looked at a few existing posts on this, but they don't seem to work for my inputs.
I have a text file where I want to extract all the text between two strings, every time that occurs.
Eg my input file is
Anna said that she would fetch the bucket.
Anna and Ben moved the bucket.... (9 Replies)
There are a lot of ways to extract text from between two strings, but what if those strings occur multiple times and you only want the text from the first two strings? I can't seem to find anything to work here. I'm using sed to process the text after it's extracted, so I prefer a sed answer, but... (4 Replies)
i have textfiles that contain a series of lines that look like this:
string0 .................................................... column3a column4a
string1**384y0439 ..................................... column3b column4b... (2 Replies)