I am trying to read a file and search for a string using grep
. Once I find the string, I want to read everything after the string until I match another string. So in my example, I am searching for ...SUMMARY...
and I want to read everything until the occurrence of ...
Here is an example:
**...SUMMARY...**
Severe thunderstorms are most likely across north-central/northeast
Texas and the Ark-La-Tex region during the late afternoon and
evening. Destructive hail and wind, along with a few tornadoes are
possible. Severe thunderstorms are also expected across the
Mid-South and Ohio Valley.
**...**North-central/northeast TX and southeast OK/ArkLaTex...
In the wake of a decaying MCS across the Lower Mississippi River
Valley, a northwestward-extending outflow boundary will continue to
modify/drift northward with rapid/strong destabilization this
afternoon particularly along and south of it. A quick
reestablishment of lower/some middle 70s F surface dewpoints will
occur into prior-MCS-impacted areas, with MLCAPE in excess of 4000
J/kg expected for parts of north-central/northeast Texas into far
southeast Oklahoma and the nearby ArkLaTex. Special 19Z observed
soundings are expected from Fort Worth/Shreveport to help better
gauge/confirm this destabilization trend and the degree of capping.
I have tried using the following code but only displays the ...SUMMARY...
and the next line.
sed -n '/...SUMMARY.../,/.../p'
What can I do to solve this?
======================================================================= Followup:
This is the result I am trying to get. Only show the paragraph under ...SUMMARY... and end at the next ... so this is what I should get in the end:
Severe thunderstorms are most likely across north-central/northeast Texas and the Ark-La-Tex region during the late afternoon and evening. Destructive hail and wind, along with a few tornadoes are possible. Severe thunderstorms are also expected across the Mid-South and Ohio Valley.
I have tried the following based on a recommendation Shellter:
sed -n '/...SUMMARY.../,/**...**/p'
But I get everything.
You may use
sed -n '/^[[:blank:]]*\.\.\.SUMMARY\.\.\./,/^[[:blank:]]*\.\.\./{//!p;}' file
See this online sed
demo.
NOTES:
/.../
just matches a line with any 3 chars^
matches the start of a line and [[:space:]]*
matches any 0+ whitespace chars{//!p;}
gets you the contents between two lines excluding those lines (see How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?)