Files
tldr/pages.zh/common/{.md

36 lines
657 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 大括号
> 多用途的 shell 语法。
> 更多信息:<https://www.gnu.org/software/bash/manual/bash.html#index-hash>。
- 隔离变量名:
`echo ${HOME}work`
- 大括号展开序列:
`echo {1..3} {a..c}{dir1,dir2,dir3}`
- 在返回文本之前检查 `variable` 是否已设置:
`echo ${variable:+variable is set and contains $variable}`
-`variable` 未设置的情况下设置默认值:
`echo ${variable:-default}`
- 返回 `variable` 的字符长度:
`echo ${#variable}`
- 返回字符串切片:
`echo ${variable:3:7}`
- 递归展开 `variable`
`echo ${!variable}`
- 将所有字符大写:
`echo ${variable^^}`