Single vs. double quotes have differences when it comes to escaping. Put
echo in front to see what actually gets sent to
$ echo egrep \' file
egrep ' file
$ echo egrep "\'" file
egrep \' file
$ echo egrep "[\']" file
egrep [\'] file
$ echo egrep '\'' file
The last case is prompting for more input because you're still within a single-quoted expression: it's not an escaped quote (
\') in single quotes (since that isn't how you escape single quotes.) It's a backslash between single quotes, with a trailing opening quote.
Incidentally, to escape a single quote in a single-quoted string, use a construction like this:
$ echo 'foo'\''bar'
What this is actually doing is putting a naked literal quote(
\') between two single-quoted strings. These are then all implicitly concatenated together.
I have no idea why
"\'" matches all lines (but it indeed seems to.)