With sed there are two ways to go with this. You can select inclusively or exclusively. In your case, an inclusive selection means printing all lines beginning with a match for '^*\*\*' up to and including one of either ^ *<np> (whatever that is) or ^$ a blank line.
An inclusive selection can be specified with any of the range expressions demonstrated in the other answers and involves specifying a start printing here pattern through to a all the way through here pattern.
An exclusive selection works in the opposite way. It specifies a stop printing before here pattern through to a start printing after here pattern. For your example data - and allowing for a stop printing before here pattern which will match either of a blank-line or that <np> thing:
sed -e 'x;/^\( *<np>.*\)*$/,/^*\** *$/c\' -e '' <infile >outfile x- Swaps hold and pattern spaces. This institutes a look-behind -
sedis always one-line behind input - and the first line is always blank.
- Swaps hold and pattern spaces. This institutes a look-behind -
/^\( *<np>.*\)*$/- This selects a stop printing before here line that matches from head to tail zero or more occurrences in the match group. Two kinds of lines can match zero or more occurrences of that - either a blank line or one with any number of <<!>spaces<!>> at the head of the line followed by the string
<np>.
- This selects a stop printing before here line that matches from head to tail zero or more occurrences in the match group. Two kinds of lines can match zero or more occurrences of that - either a blank line or one with any number of <<!>spaces<!>> at the head of the line followed by the string
/^*\** *$/- This selects a start printing after here line which opens with at least one
*asterisk character and continues to the end of the line with only zero or more occurrences of the*asterisk and possibly closed by any number of spaces.
- This selects a start printing after here line which opens with at least one
c\' -e ''- This
changes the entire blocked selection to a single blank line, squeezing all unwanted lines to the stringEOF.
- This
So any number of lines occurring before ^*\** *$ and after the first following ^\( *<np>.*\)*$ are always squeezed down to only a single blank, and only the first occurring paragraph after a match for ^*\** *$ is printed to stdout. It prints...
2012/10/01 00:00:00.000 6998.239 0.001233 97.95558 77.41733 89.98551 290.75808 359.93398 2012/10/01 00:05:00.000 6993.163 0.001168 97.95869 77.41920 124.72698 274.57362 359.93327 2012/10/01 00:10:00.000 6987.347 0.001004 97.96219 77.42327 170.94020 246.92395 359.94706 2012/10/01 00:15:00.000 6983.173 0.000893 97.96468 77.42930 224.76158 211.67042 359.97311
That assumes you want to handle any number of occurrences of the paragraph pattern in input. If you only want the first however, provided you have GNU grep and that infile is a regular, lseekable file:
{ grep -xm1 '*\** *' >&2 sed -n '/^\( *<np>.*\)*$/q;p' } <infile 2>/dev/null >outfile ... will work as well.