Linux find & grep multiple phrasses in file efficiently

P

postcd

Guest
Hello,

im having Linux "find" command in a bash script

im searching thru linux filesystem and for each found file i need to search this file for around 20 phrasses

I have question how i most efficiently search for these phrasses in each file the "find" command return?

I found command: grep -f pattern_file.txt input_file.txt

so im curious if i can anyhow adjust it to read the find output file for 20 phrasses in one go..

so i dont need to do any "for" loop which i assume would be less efficient? than using stock "grep" command which do search all phrasse sin one go?

an idea i got:

variable="line1
line2
line3"

find / -type f -exec grep $variable {} \;

thank you for ideas
 


IMHO given the criteria your approach would be the most practical and efficient.

Good luck ;)
 

Members online


Top