I have a collection of files. I want to search through them all with
grep to find all and only those which contain anywhere within them both the strings
I would also like to know how to do this with awk.
For grep, the pipe symbol separates strings in a combination regexp; on some systems, it may be necessary to use egrep to activate this functionality:
I would expect the syntax to be similar for awk.
You have clarified your request, so here's how to do it with grep:
This will search all the files in a given directory (
Search in one file
Using grep to find lines with either "keyword1" or "keyword2" in the file "myfile.conf":
The escaping of the pipe
Search in all files in a directory
To search for files containing either "keyword1" or "keyword2" in a directory:
If you want to do a case-insensitive search, add the
If I understand correctly, you want to search all the files which contains