How to find (f'
or (f"
or ("
or ('
with grep?
For example the regex could be (f\?["']
but how to pass this to grep - it can't be surrounded by quotation marks neither by apostrophes?
This pattern in your question f\?["']
matches an f
char followed by ?
and one of "
or '
If the text is for example in file
, you might use:
grep -Eo "(\(|\bf)['\"]" file
The pattern matches:
(
Start group
\(
Match (
|
Or\bf
A word boundary followed by matching f
)
Close the group['\"]
Match either '
or "
Output
f'
f"
("
('