Search for two words in a File
Matt Davey
mcdavey at mrao.cam.ac.uk
Wed Apr 26 13:52:03 UTC 2006
On Wed, 2006-04-26 at 12:53 +0100, Paul Howarth wrote:
> Tim wrote:
> > On Wed, 2006-04-26 at 10:50 +0100, Paul Howarth wrote:
> >> grep -E 'deep|html' test
> >
> > Wouldn't that match against *either* word, rather than require both to
> > be present?
>
> Yes, but that's what I thought the OP was looking for.
>
> To look for both words in the same line, I'd use:
>
> $ grep deep test | grep html
And to require both words to be present anywhere in the file you could
use:
grep -q deep test && grep -q html test && echo "found both"
Matt
Matt Davey If we knew what we were doing, it wouldn't be
mcdavey at mrao.cam.ac.uk research. If we knew how it was going to come
out, it wouldn't be an experiment.
More information about the fedora-list
mailing list