在扩展模式匹配运算符中包含路径部分

Including path portions in xtended pattern matching operators

给定以下目录结构,其中所有叶子都是文件,

a
├── b
│   ├── d
│   │   └── f
│   └── e
│       └── g
└── c
    ├── d
    │   └── h
    └── e
        └── i

以下命令列出文件 fh

$ ls a/@(b|c)/d/.

但以下未能列出 fi

$ ls a/@(b/d|c/e)
ls: cannot access 'a/@(b/d|c/e)': No such file or directory

显然,我不能在 pattern-list 中添加斜杠。我的问题是一个,但也许把它分成几块更好:

我的直觉告诉我 Filename Expansion 可以生成 filenames 但不能生成 pathnames。

在这种情况下您可以使用 Brace Expansion 不过:

ls a/{b/d,c/e}