${name:q}
: Quote words
Escapes special characters of the variable value.
Use :x
if you’d like to break into words at whitespace.
Please note that :x
does not work with parameter expansion.
Links
Examples
- Quote variable value
- Output:
1 2
code="echo Pattern is *.txt" echo $code:q
1
echo\ Pattern\ is\ \*.txt
BashSupport Pro is a Zsh IDE with support for $varName:q – try it now!