Parsing Multiple Lines of stdout in Bash

Hello all,

I am trying to pipe an output to something like sed or awk to parse it based on my delimiter. However, I am struggling with the fact that sed reads line-by-line - so, my use of Regex is not effective.


Some text I do not want
The text I do care about
Some more text I do not want


The text I do care about

Note: I want to preserve spaces and tabs, and what-have-you within the delimiter bounds.

What I thought would work:

sed -E 's/[\s\S]+--fcc--([\s\S]+?)--fcc--[\s\S]+/\1/'

I have read through most of sed's manual, and tried to make the Text search across multiple lines work, but do not understand it well enough I guess :man_shrugging:

Something to play with:

Any help is appreciated

1 Like

Sometimes, I feel like I use this forum as my debugger duck :duck:

The solution came from following this:

Nothing more than:

sed -n '/--fcc--/, /--fcc--/{ /--fcc--/! p }'
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.