realguess
realguess

Reputation: 1151

How to use Bash extended pattern to match files from the current directory and from one of the subdirectories

For example, the following directory structure:

$ tree
.
├── app.js
├── lib
│   └── util.js
└── test
    └── main.js

2 directories, 3 files

I would like to match js files from the current directory and lib/ directory, sort of like:

$ ls *.js lib/*.js
app.js  lib/util.js

but in a single glob. And this does not do it:

ls @(.|lib)/*.js

any ideas?

Upvotes: 0

Views: 124

Answers (1)

devnull
devnull

Reputation: 123608

I doubt if a glob would do the intended. You could use brace expansion, however:

echo {.,lib}/*.js

Upvotes: 1

Related Questions