grep count matches code example
Example 1: grep 2 matches or
Just use one of following forms with grep or egrep commands :)
grep "PATTERN1\|PATTERN2" FILE
grep -E "PATTERN1|PATTERN2" FILE
grep -e PATTERN1 -e PATTERN2 FILE
egrep "PATTERN1|PATTERN2" FILE
Example 2: grep count lines
grep -c ^ filename
Example 3: grep ocurrences
Just use flag -m to define number of occurrences to match:
grep -m1 pattern file