How to search a text file for strings between two tokens in Ubuntu terminal and save the output?
Posted
by
Blue
on Super User
See other posts from Super User
or by Blue
Published on 2014-06-04T11:19:28Z
Indexed on
2014/06/04
21:29 UTC
Read the original article
Hit count: 237
How can I search a text file for this pattern in Ubuntu terminal and save the output as a text file?
I'm looking for everything between the string "abc" and the string "cde" in a long list of data.
For example:
blah blah abc fkdljgn cde blah
blah blah blah blah blah abc skdjfn cde blah
In the example above I would be looking for an output such as this:
fkdljgn
skdjfn
It is important that I can also save the data output as a text file.
Can I use grep or agrep and if so, what is the format?
© Super User or respective owner