Bash Escape Special Postacie w zmiennej
# Use Shell Parameter Expansion:
foo_esc="${foo@Q}"
VasteMonde
# Use Shell Parameter Expansion:
foo_esc="${foo@Q}"
#You can use the %q format specifier with printf to take care of the variable escaping for you:
#source: https://serverfault.com/questions/625641/how-can-i-run-arbitrarily-complex-command-using-sudo-over-ssh
cmd="ls -al"
printf -v cmd_str '%q' "$cmd"
ssh user@host "bash -c $cmd_str"
use "\" to use the literal value of the next character (except newline)