Subject: one-liner smart Perl command instead of a simple grep (in Bash script)
I have a problem when I use grep to match the unusual characters (I can\'t put the \"\\\"
You could do something like this:
perl -ne 'print if m|\Q[ * ( & % \E\@\Q !]\E|' file
I've found the \Q and \E operator in Quote and Quote-like Operators.
A snippet from that link:
You cannot include a literal $ or @ within a \Q sequence. An unescaped $ or @ interpolates the corresponding variable, while escaping will cause the literal string \$ to be inserted. You'll need to write something like m/\Quser\E@\Qhost/.
\Q Quote (disable) pattern metacharacters till \E or end of string \E End either case modification or quoted section (whichever was last seen)