Usually grep
outputs any lines that match a pattern. I want to be able to find lines that match the pattern multiple times. For example, if my search pattern was "foo", then:
foo bar # Would not be matched
foo foo bar # Would be matched
bar foofoo # Would be matched
foobarfoo # Would be matched
Is there a way I can tell grep
to find only lines that contain multiple matches of my search pattern?
grep
has no such option.grep "${pattern}.*${pattern}"
does what you want, though.bob
, would you say it matches twice onbobob
? In another words, are the matches required to be disjoint or not?<.*>
on an input like<a<b>c>
where you could say there's only one or there are 4 matches (<a<b>
,<a<b>c>
,<b>
,<b>c>
)