> Shell parsing is hard.
In general, not for SSH specifically, I tend to close quoted bash strings instead of trying to figure out how many escapes I need. Especially useful for awk and sed.
For example:
$ echo "One Two Three" | awk '{print "'"'"'"$2" here'"'"'"}'
'Two here'
Ok, maybe escapes would have been easier in this particular example. $ echo "One Two Three" | awk '{print "\'"$2" here\'"}'
>
No wait, that doesn't work. Why didn't that work? $ echo "One Two Three" | awk '{print "\\'"$2" here\\'"}'
awk: cmd. line:1: {print "\\
awk: cmd. line:1: ^ unterminated string
awk: cmd. line:1: {print "\\
awk: cmd. line:1: ^ syntax error
...Nevermind, my original way is still better for me.