I'm hoping to write a bash script to grep files matching several strings.
I've found the 'hard-wired' solution here: (Source: Find files containing multiple strings):
find . -type f -exec grep -l 'string1' {} \; | xargs grep -l 'string2' | xargs grep -l 'string3' | xargs grep -l 'string4'
Would return all files containing string1 && string2 && string3 && string4.
How can I convert this into a bash shell function fn that takes in an arbitrary number of arguments? I'd like fn string1 string2 string3 string4 ... to give me identical results. Persumably this would involve looping through arguments and piping results to successive commands xargs grep -l ${!i}