bash的基础特性之:命令行展开
~:自动展开为用户的家目录,或指定的用户的家目录;
{}:可承载一个以逗号分隔的路径列表,并能够将其展开为多个路径;
例如:创建/tmp/a1, /tmp/a2, /tmp/a1/a, /tmp/a1/b,
[root@localhost ~]# ll /tmp/
total 8
drwxr-xr-x. 2 root root 98 May 19 11:57 mytest1
-rw-r--r--. 1 root root 465 May 19 16:04 testcp.txt
-rw-r--r--. 1 755 root 26 May 4 2015 test.file
drwxr-xr-x. 2 root root 6 May 19 11:47 tfile-2019-05-19-11-47-16
-rw-rw-r--. 1 user1 user1 0 May 19 16:07 user2.txt
drwx------. 2 root root 6 May 19 11:35 vmware-root
[root@localhost ~]# mkdir -pv /tmp/{a1/{a,b},a2}
mkdir: created directory ‘/tmp/a1’
mkdir: created directory ‘/tmp/a1/a’
mkdir: created directory ‘/tmp/a1/b’
mkdir: created directory ‘/tmp/a2’
[root@localhost ~]# ll /tmp/
total 8
drwxr-xr-x. 4 root root 24 May 19 17:39 a1
drwxr-xr-x. 2 root root 6 May 19 17:39 a2
drwxr-xr-x. 2 root root 98 May 19 11:57 mytest1
-rw-r--r--. 1 root root 465 May 19 16:04 testcp.txt
-rw-r--r--. 1 755 root 26 May 4 2015 test.file
drwxr-xr-x. 2 root root 6 May 19 11:47 tfile-2019-05-19-11-47-16
-rw-rw-r--. 1 user1 user1 0 May 19 16:07 user2.txt
drwx------. 2 root root 6 May 19 11:35 vmware-root
[root@localhost ~]#
在/tmp目录下创建目录:x_y, x_z, q_y, q_z
[root@localhost ~]# ll /tmp/
total 8
drwxr-xr-x. 4 root root 24 May 19 17:39 a1
drwxr-xr-x. 2 root root 6 May 19 17:39 a2
drwxr-xr-x. 2 root root 98 May 19 11:57 mytest1
-rw-r--r--. 1 root root 465 May 19 16:04 testcp.txt
-rw-r--r--. 1 755 root 26 May 4 2015 test.file
drwxr-xr-x. 2 root root 6 May 19 11:47 tfile-2019-05-19-11-47-16
-rw-rw-r--. 1 user1 user1 0 May 19 16:07 user2.txt
drwx------. 2 root root 6 May 19 11:35 vmware-root
[root@localhost ~]# 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’
[root@localhost ~]# ll /tmp/
total 8
drwxr-xr-x. 4 root root 24 May 19 17:39 a1
drwxr-xr-x. 2 root root 6 May 19 17:39 a2
drwxr-xr-x. 2 root root 98 May 19 11:57 mytest1
drwxr-xr-x. 2 root root 6 May 19 17:40 q_y
drwxr-xr-x. 2 root root 6 May 19 17:40 q_z
-rw-r--r--. 1 root root 465 May 19 16:04 testcp.txt
-rw-r--r--. 1 755 root 26 May 4 2015 test.file
drwxr-xr-x. 2 root root 6 May 19 11:47 tfile-2019-05-19-11-47-16
-rw-rw-r--. 1 user1 user1 0 May 19 16:07 user2.txt
drwx------. 2 root root 6 May 19 11:35 vmware-root
drwxr-xr-x. 2 root root 6 May 19 17:40 x_y
drwxr-xr-x. 2 root root 6 May 19 17:40 x_z
[root@localhost ~]#
创建如下目录结构:
[root@localhost ~]# mkdir -pv /tmp/mysysroot/{bin,etc/sysconfig/network-scripts,sbin,usr/{bin,lib,lib64,local/{bin,lib,sbin}},sbin,var/{cache,log,run}}
mkdir: created directory ‘/tmp/mysysroot’
mkdir: created directory ‘/tmp/mysysroot/bin’
mkdir: created directory ‘/tmp/mysysroot/etc’
mkdir: created directory ‘/tmp/mysysroot/etc/sysconfig’
mkdir: created directory ‘/tmp/mysysroot/etc/sysconfig/network-scripts’
mkdir: created directory ‘/tmp/mysysroot/sbin’
mkdir: created directory ‘/tmp/mysysroot/usr’
mkdir: created directory ‘/tmp/mysysroot/usr/bin’
mkdir: created directory ‘/tmp/mysysroot/usr/lib’
mkdir: created directory ‘/tmp/mysysroot/usr/lib64’
mkdir: created directory ‘/tmp/mysysroot/usr/local’
mkdir: created directory ‘/tmp/mysysroot/usr/local/bin’
mkdir: created directory ‘/tmp/mysysroot/usr/local/lib’
mkdir: created directory ‘/tmp/mysysroot/usr/local/sbin’
mkdir: created directory ‘/tmp/mysysroot/var’
mkdir: created directory ‘/tmp/mysysroot/var/cache’
mkdir: created directory ‘/tmp/mysysroot/var/log’
mkdir: created directory ‘/tmp/mysysroot/var/run’
[root@localhost ~]# tree /tmp/mysysroot/
/tmp/mysysroot/
├── bin
├── etc
│ └── sysconfig
│ └── network-scripts
├── sbin
├── usr
│ ├── bin
│ ├── lib
│ ├── lib64
│ └── local
│ ├── bin
│ ├── lib
│ └── sbin
└── var
├── cache
├── log
└── run
17 directories, 0 files
[root@localhost ~]#