Reg python regexp
On 21/03/18 10:44, sankarramanv at gmail.com wrote:
> I have a requirement.
> cmd="cat <file>|grep -c 'if [ -t 1 ]; then mesg n 2>/dev/null; fi'"
> I need to escape only the square brackets in above variable since its not grepping without escaping the brackets.
You need to escape the square brackets as you normally would for your
shell, with backslashes I presume. Then you need to escape the
backslashes so they aren't interpreted specially by Python, with more
Rhodri James *-* Kynesim Ltd