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 "\" before each unusual character, because it's very problematic and not a smart solution).
I need Perl one-liner syntax that match exactly all the unusable characters as defined in the $Some_string. Examples:
Examples
Some_string="[234-094]"
Some_string="[ * ( & % @ !]"
Some_string="~ [ 0:3 # % & ^ + =]"
Some_string="1.1.1.1.-9.9.9.9 + 9999.999.1 – 10000"
Some_string="< { [ ' : ; " ? / . , "
Some_string="PORT.A.B.C.D – 124.543.455.33 – [ ! NOT EQUAL PORT 38737 – 3837652"
.
.
.
My bad grep syntax
cat file | grep $Some_string
With Perl (I need the following right suggestion/solution):
cat file | perl -nle 'print if /$Some_string/'
Rules
Remark: if Some_string="111.111.111.111" and in the file I have 1111.1111.1111.1111 then the Perl syntax needs to ignore this. Perl must match only if I have this in the file: 111.111.111.111 .
Second remark: if Some_string="WORD" and in the file I have: ONEWORD then the Perl syntax needs to ignore this. Perl must match only if I have this in the file: WORD