1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages.zh/common/$.md
Yi Liu 653919fa00
pages.zh/common/*: update Chinese translation (#15962)
Co-authored-by: Managor <42655600+Managor@users.noreply.github.com>
2025-03-26 06:38:15 +02:00

563 B

Dollar sign

展开 Bash 变量。 更多信息:https://gnu.org/software/bash/manual/bash.html#Shell-Variables.

  • 打印变量的值:

echo ${{变量名}}

  • 打印上一个命令的退出状态:

echo $?

  • 打印 0 到 32767 之间的随机数:

echo $RANDOM

  • 打印其中一个提示字符串:

echo ${{PS0|PS1|PS2|PS3|PS4}}

  • 运行 命令 并展开它的输出。与将 命令 括在反引号中相同:

$({{命令}})

  • 列出当前上下文有多少个参数:

echo $#

  • 打印 Bash 数组:

echo ${array[@]}