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 \"\\\"
I'm not sure I understand your question, exactly. Perhaps -P
and -x
do what you want, along with quoting "$Some_string"
to preserve whitespace?
grep -Px "$Some_string" file
From the grep man page:
-P
,--perl-regexp
Interpret PATTERN as a Perl regular expression.
-x
,--line-regexp
Select only those matches that exactly match the whole line.