hello, I want to write a script to find all the files that contain 3 specific patterns. example: shows the files containing any line that contain pattern1, pattern2 and pattern3, but the patterns can be in any order as long as they exist in the line.
can I do that with grep?
thank you
Under any Unix or Linux, to find...:
- by searching from /your_start_dir directory
- all files with .txt extension
- also by following symbolic links, if any
- for each such file, execute a regular expression search with :
- _Extended grep
- _list only file names (without -l, will also print found lines)
- do the search case _insensitive
- search pattern pat1 or pat2 or pat3
type this command:
find /your_start_dir -name '*.txt' -follow -exec grep -E -l -i 'pat1|pat2|pat3' {} \;