How to escape \ in grep commands in stdin?

Viewed 34

I had setup a few continuous commands on paramiko, I need to input \ in the grep query to be able to get the desired output. Here's the snippet,

stdin.write('''
    cd dump-{}
    grep -rl siteId\":\"{} *.json
    exit
    '''.format(timestamp,store))

But the stdout.readlines displays the input to be,

grep -rl siteId":"16017

Whereas the desired input is

grep -rl siteId\":\"16017

So that I can escape the double inverted commas. Can someone tell me how to do so?

0 Answers
Related