Whenever you need to use a single-quote on command line add a $ sign before it. It makes escaping everything super easy
su user -c $'cd \'$dir\' && ...'
More details are here: https://stackoverflow.com/a/16605140/1031454
$ echo 'hello \"world' hello \"world $ echo $'hello \"world' hello "world
Whenever you need to use a single-quote on command line add a $ sign before it. It makes escaping everything super easy
Before this it used to confuse the hell out of me.More details are here: https://stackoverflow.com/a/16605140/1031454