I know that I can find certain types of files and then grep them with one shot, i.e.
find . -type f -name "*.log" -exec grep -o "some-pattern" {} \;
But I need to do this in two steps. This is due to the fact that the search operation is expensive (there are many files and subdirectories for searching). I would like to save the file list to a text file and then re-grep for the different templates in this pre-computed set of files whenever I need. The first part is simple:
find . -type f -name "*.log" > my-file-list.txt
Now I have a file that looks like this:
./logs/log1.log ./logs/log2.log etc
What does grep look like? I tried several combinations, but I can not understand.
Ismail degani
source share