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:


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?

  • 1
    I think it is a dirty shellhack, dots always need special treatment when they are in a specific role. – vakufo Mar 12 '12 at 18:47
  • 2
    Hi. Sorry. I made a mistake. It is not ... but **. I have changed the original post. – Kevin Zhang Mar 12 '12 at 19:13

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.