${(Q)…}: Remove one level of quotes

Q removes one level of quotes from the resulting words.

Examples

Remove quotes
1
2
3
4
5
6
double_quoted="\"'double quoted string'\""
echo ${double_quoted}
# remove one level of quotes
echo ${(Q)double_quoted}
# remove two levels of quotes
echo ${(Q)${(Q)double_quoted}}
Output:
1
2
3
"'double quoted string'"
'double quoted string'
double quoted string
BashSupport Pro is a Zsh IDE with support for ${(Q)…}try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal