${(#)…}: Evaluate as character codes

Evaluates the resulting words as character codes and converts them into corresponding characters.

Examples

Print message using ASCII values
1
2
3
4
5
6
7
# decimal ASCII values
ascii=(72 101 108 108 111)
echo ${(#)ascii}
  
# hex ASCII values
ascii=(0x57 0x6F 0x72 0x6C 0x64)
echo ${(#)ascii}
Output:
1
2
H e l l o
W o r l d
BashSupport Pro 是一款支持 #** 的 **Zsh 集成开发环境 - 立即试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款