Match exactly (and only) the pattern I specify in a grep command
- by palswim
Usually, grep searches for all lines containing a match for the pattern/parameter I specify.
I would like to match just the pattern (i.e. not the whole line).
So, if a file contains the lines:
We said that we'll come.
Unfortunately, we were delayed.
Now, we're on our way.
I want to find all contractions starting with "we" (regex pattern: we\'[a-z]+/i). And I'm looking for the output:
we'll
we're
How do I do this (with grep or another Unix/Windows command-line tool)?