Enlico
Enlico

Reputation: 28490

Including path portions in xtended pattern matching operators

Given the following directory structure, where all leafs are files,

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

the following command lists the files f and h

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

but the following fails in listing f and i

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

Clearly, I cannot put slashes in the pattern-list. My question is one, but maybe breaking it into pieces is better:

Upvotes: 1

Views: 27

Answers (1)

glenn jackman
glenn jackman

Reputation: 247072

My gut is telling me that Filename Expansion can generate filenames but not pathnames.

This is a case where you can use Brace Expansion though:

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

Upvotes: 2

Related Questions