Re: Reg python regexp

2018-03-21 Thread Youta TAKAOKA
sankarramanv, It seems for me that this task does not need both python AND shell. Only python does it, as well as only shell. Of course, there can be some restrictions let you use both. (the real world is filled up with such troublesome matters !) If you *really* need to use `lgrep`, try `-f` opt

Re: Reg python regexp

2018-03-21 Thread Rhodri James
On 21/03/18 10:44, sankarram...@gmail.com wrote: Hi, I have a requirement. cmd="cat |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 a

Re: Reg python regexp

2018-03-21 Thread Chris Angelico
On Wed, Mar 21, 2018 at 9:44 PM, wrote: > Hi, > > I have a requirement. > > cmd="cat |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. > > Please help. You're putting this

Re: Reg python regexp

2018-03-21 Thread Paul Moore
Hi, You don't need a regexp for this, the "replace" method on a string will do what you want: >>> s = 'this is a [string' >>> print(s.replace('[', '\\[')) this is a \[string Paul On 21 March 2018 at 10:44, wrote: > Hi, > > I have a requirement. > > cmd="cat |grep -c 'if [ -t 1 ]; then mesg n

Reg python regexp

2018-03-21 Thread sankarramanv
Hi, I have a requirement. cmd="cat |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. Please help. Thanks. -- https://mail.python.org/mailman/listinfo/python-list