Shell – the tool that allows me to specify arbitrary directories using **

command linedirectoryrecursiveshellwildcards

I once saw a colleague uses a tool which allows to use ** to represent any directories. For example: if a file called myfile.java sits deep inside:

src/main/com/mycompany/product/store/myfile.java

A command in the parent of src directory:

ls **/myfile.java

can list the file.

Can anyone tell me what tool it is? What package I need to use on Ubuntu to achieve this?

Best Answer

In bash ≥4.0, turn on the globstar option.

$ shopt -s globstar
$ echo pylib/**/pyerector.py
pylib/pyerector.py pylib/pyerector/pyerector.py

You can read more about it in the manpage.

In zsh, this is available out of the box.

In ksh93, activate it with set -o globstar.

In plain sh or bash ≤3.x, this is not available.