I want the text not matching the pattern to be gone
keep-lines will delete lines not matching the pattern (i.e. only keep the lines which match).
flush-lines does the opposite, deleting lines which do match the pattern.
occur will open a separate buffer showing only the matching lines (which you can use like a compilation error buffer to navigate those positions in the original buffer). This option is the closest to the 'grep' approach.
occur will show only the portion of each line which specifically matched the pattern (which is what the quoted part of your question sounds most like).
loccur from https://elpa.gnu.org/packages/loccur.html hides/unhides the text within the original buffer (which is therefore a bit like a non-destructive
You can read about those built-in commands, and others, in the manual:
(emacs)Other Repeating Search
(emacs)Compilation Mode regarding the convenient navigation using the
Finally, note that if you do need to use
grep itself, you are better off doing that inside Emacs as well (not least because you can once again jump from the results to the original locations like in a compilation buffer). There are many Emacs commands which use grep, and you can read about those at:
Tangentially, I'll recommend the third-party grep equivalent to Occur Edit mode, which you can find at https://melpa.org/#/wgrep.