How can I properly escape arbitrary commands?
For example:
sudo -u chris sh -c 'echo "\"leftright\""'
The above echos:
"leftright"
How would I echo out:
"left'right"
I've tried the following which I would expect to work but does not:
sudo -u chris sh -c 'echo "\"left\'right\""'
I can't quite get my head round how it is parsed.
sh -c 'echo \"left"'\''"right\"'
. Check this for reference. Also check here for a good explanation by liori – neuron Jul 19 '15 at 19:47