oxygen_728
asked on
Linux - Grep - How do I search for two terms at once?
I want to search for all files that contain both "password" and "_PUT"
How would i do this on a grep search?
Thanks
How would i do this on a grep search?
Thanks
ASKER
I'd prefer on the same line,
but i'd like to know how to do it in the same file too
Thanks for your time
but i'd like to know how to do it in the same file too
Thanks for your time
put the different strings in a file e.g. myfile
string1
string2
then use grep -f myfile *
string1
string2
then use grep -f myfile *
ASKER
Omar, does that search for them on the same line?
Do I put quotes around my strings?
Does that search for both terms using an AND conjunction or an OR conjunction?
Thanks
Do I put quotes around my strings?
Does that search for both terms using an AND conjunction or an OR conjunction?
Thanks
no, this is an OR so either string1 or string2 or .....
if in the same line the use
string1*string2
if in the same line the use
string1*string2
ASKER
Omar, I cannot seem to get that to work
can you provide a more detailed example?
can you provide a more detailed example?
also,you can do
grep string1 * | grep string2 | grep string3
I could not do it with string1*string2
grep string1 * | grep string2 | grep string3
I could not do it with string1*string2
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ghost, is there some way to alternatively check a file for both of those that don't necessarily occur on the same line?
Thanks
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
grep -l password `grep -l _PUT *`
On the same line or anywhere in the file?
Kent