This question was asked ten years ago, so I won’t mark it as duplicate. Also I noticed no sed solution was given since OP asked an answer without:
sed -nr 's/(hello[0-9]+), please match me/\1/p' test.txt
-n
stands for quiet (won’t print anything except if explicitly asked)-r
allows use of extented regular expressions (avoids here using\
before parenthesis)s/reg/repl/p
command means “if regexpreg
matches the current line, replace it by captured text byrepl
, and prints it (/p
)”