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 keyword1 and keyword2.
I would also like to know how to do this with awk.
feedback
|
|
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. Edit: yup:
Edit 2: You have clarified your request, so here's how to do it with grep:
This will search all the files in a given directory ( | |||||||||
feedback
|
Search in one fileUsing 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 directoryTo search for files containing either "keyword1" or "keyword2" in a directory:
If you want to do a case-insensitive search, add the | |||
|
feedback
|
|
If I understand correctly, you want to search all the files which contains
| |||
|
feedback
|