top of page

Use Grep Utility to Collect Full Lines on Which Search Terms Appear


The Tip of the Night for August 4, 2018, discussed how to run Regex searches for multiple strings, collecting the complete line on which they appear. The tip showed how to do this using the grep utility, PowerGrep. Here's a slightly different approach using a list of separate search terms not written in the regular expression syntax.

1. In PowerGrep, select the folder which contains the files you want to search through in the directory tree at the left.

2. Set the action type to 'Collect Data'.

3. Set file sectioning to 'line by line'.

4. Check off the box for 'Collect/replace whole sections'

5. Set the search type to 'List of literal text'

6. Enter a string to search for in the search box, and then press the green plus icon to add additional lines.

7. For each search term, in the collect box enter: \0 to get the terms searched for (all with the complete line). You can also add %PATH% %FILENAME% to collect the file path and file names of the files you are searching.

8. Set target file creation to 'Save results into a single file' and in Target file location, enter a .csv file in which to export the search results.

9. Click Collect, and as you can see PowerGrep will collect the full line on which each search term appears.


bottom of page