PowerGREP’s file sectioning feature makes it trivial to extract and delete lines, or any other kind of file section. Follow these steps to extract all lines matching at least one of the search terms:
To extract the lines into new files, set the target type to “save one file for each searched file”. Set “between collected text” to “Line break”. Then click the Collect button.
To delete the lines from the original files instead, set the action type to “search and delete” in step 3 above. If you set the file sectioning type to “line by line”, matching lines will be blanked out, but the number of lines in the file will remain the same. If you set it to “line by line (including line breaks), then the lines will be completely deleted, and the number of lines in the file will shrink.
The above steps will extract or delete any line that contains at least one of the search terms. If a line must contain all search terms in order to be extracted or deleted, turn on the option “list only sections matching all items”. This option becomes visible after you set the file sectioning type to “line by line”.
For more complex combinations of search terms, see the example about boolean operators.
To extract or delete those lines that do not contain any of the search terms, turn on the “invert search results” option in the file sectioning. When using a list of search terms, make sure “list only sections matching all terms” is off.
If you turn on both “invert search results” and “list only sections matching all terms” then you will extract or delete all lines that contain none of the search terms as well as all lines that contain some but not all of the search terms.