bash的命令行展開特性
阿新 • • 發佈:2018-06-02
bash~: 自動展開為用戶的家目錄,或指定的用戶的家目錄
示例:
[root@node1 network-scripts]# cd ~
[root@node1 ~]#
{}: 可承載一個以逗號分隔的路徑列表,並能夠將其展開為多個路徑
示例: 在/tmp創建以下目錄,a_c,a_d,b_c,b_d
[root@node1 ~]# mkdir -v {a,b}_{c,d} mkdir: created directory ‘a_c’ mkdir: created directory ‘a_d’ mkdir: created directory ‘b_c’ mkdir: created directory ‘b_d’
示例: 在/tmp/mylinux下創建目錄結構
[root@node1 ~]# mkdir -pv /tmp/mylinux/{bin,etc/sysconfig/network-scripts,sbin,usr/{bin,lib,lib64,local/{bin,etc,lib,sbin},sbin},var/{cache,log,run}} mkdir: created directory ‘/tmp/mylinux’ mkdir: created directory ‘/tmp/mylinux/bin’ mkdir: created directory ‘/tmp/mylinux/etc’ mkdir: created directory ‘/tmp/mylinux/etc/sysconfig’ mkdir: created directory ‘/tmp/mylinux/etc/sysconfig/network-scripts’ mkdir: created directory ‘/tmp/mylinux/sbin’ mkdir: created directory ‘/tmp/mylinux/usr’ mkdir: created directory ‘/tmp/mylinux/usr/bin’ mkdir: created directory ‘/tmp/mylinux/usr/lib’ mkdir: created directory ‘/tmp/mylinux/usr/lib64’ mkdir: created directory ‘/tmp/mylinux/usr/local’ mkdir: created directory ‘/tmp/mylinux/usr/local/bin’ mkdir: created directory ‘/tmp/mylinux/usr/local/etc’ mkdir: created directory ‘/tmp/mylinux/usr/local/lib’ mkdir: created directory ‘/tmp/mylinux/usr/local/sbin’ mkdir: created directory ‘/tmp/mylinux/usr/sbin’ mkdir: created directory ‘/tmp/mylinux/var’ mkdir: created directory ‘/tmp/mylinux/var/cache’ mkdir: created directory ‘/tmp/mylinux/var/log’ mkdir: created directory ‘/tmp/mylinux/var/run’ [root@node1 ~]# tree /tmp/mylinux/ /tmp/mylinux/ ├── bin ├── etc │?? └── sysconfig │?? └── network-scripts ├── sbin ├── usr │?? ├── bin │?? ├── lib │?? ├── lib64 │?? ├── local │?? │?? ├── bin │?? │?? ├── etc │?? │?? ├── lib │?? │?? └── sbin │?? └── sbin └── var ├── cache ├── log └── run 19 directories, 0 files
tree命令:
以樹狀結構列出目錄內容。
語法: tree [options] [directory]
選項: -L level: 指定要顯示的層級
安裝: yum -y install tree
bash的命令行展開特性