“Bash Escape Tous les caractères spéciaux” Réponses codées

Bash Escape Caractères spéciaux en variable

# Use Shell Parameter Expansion:
foo_esc="${foo@Q}"
VasteMonde

Bash Escape Tous les caractères spéciaux

#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"
Condemned Cat

Échapper aux personnages de bash

use "\" to use the literal value of the next character (except newline)
Upset Unicorn

Réponses similaires à “Bash Escape Tous les caractères spéciaux”

Questions similaires à “Bash Escape Tous les caractères spéciaux”

Plus de réponses similaires à “Bash Escape Tous les caractères spéciaux” dans Shell/Bash

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code