Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash escape all special characters

#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"
Source by www.gnu.org #
 
PREVIOUS NEXT
Tagged: #bash #escape #special #characters
ADD COMMENT
Topic
Name
6+3 =