花括号是可以让bash生成任意字符串的一咱扩展功能。

在Linux bash中,命令有时会有多个参数。当多个参数的内容部分相同或连续时,就可以使用花括号“{}”来简化参数的内容。

示例

创建目录:/tmp/a1,/tmp/a2,/tmp/a1/a,/tmp/a1/b

[root@192 ~]# mkdir -pv /tmp/a{1/{a,b},2}

mkdir: created directory ‘/tmp/a1’

mkdir: created directory ‘/tmp/a1/a’

mkdir: created directory ‘/tmp/a1/b’

mkdir: created directory ‘/tmp/a2’

在/tmp目录下创建目录:x_y,x_z,q_y,q_z

[root@192 ~]# mkdir -pv /tmp/{x,q}_{y,z}

mkdir: created directory ‘/tmp/x_y’

mkdir: created directory ‘/tmp/x_z’

mkdir: created directory ‘/tmp/q_y’

mkdir: created directory ‘/tmp/q_z’