bash的基础特性之:命令行展开

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 ~]# 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值