while grep -m 1 PATTERN do echo xxxx done < FILE
But the following probably will not work because a pipe is not a regular file:
# This probably will not work. cat FILE | while grep -m 1 PATTERN do echo xxxx done
When grep stops after num matching lines,
it outputs any trailing context lines.
Since context does not include matching lines,
grep will stop when it encounters another matching line.
When the -c or --count option is also used,
grep does not output a count greater than num.
When the -v or --invert-match option is also used,
grep stops after outputting num non-matching lines.