Monday, 20 May 2013

Why escaped single quote doesn't work in grep?

Why escaped single quote doesn't work in grep?

I am trying to match a string:
* * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw
with:
crontab -l | grep '^[^#].*/usr/local/bin/growlnotify.*\-n \'myApp\'.*$'
it doesn't work: nothing matched.
But:
crontab -l | grep '^[^#].*/usr/local/bin/growlnotify.*\-n.*$'
works very good:
* * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw
What is the problem with \'myApp\' ?
How to escape a single quote in grep/sed?

No comments:

Post a Comment