You want wildcard expansion to find a path anywhere on the system. You can do that, if you specify the pattern correctly:
will work in zsh and fish by default, in Bash if you first
shopt -s globstar, in tcsh if you
set globstar, in ksh93 if you
set -o globstar, in
yash if you
set -o extended-glob.
This works because the wildcard is used within an absolute path starting with
/ instead of being relative to the current directory, and when you opt into using the
** pattern it expands to any number of subdirectories.
While this will work, it is likely to take an extremely long time. Your shell has to search your entire system for the matching file(s). You can cut that down by providing a longer prefix to trim out more of the search space:
The further you drill down the less searching there will be to do. If the directory tree is fairly sparse, this won't take too long and is actually practical to use. The trailing
/ ensures that the expansion is only to a directory, which removes one variety of ambiguity that could occur.
If there's more than one match still, the result will depend on your shell. Bash and fish will switch to the alphabetically first match, ignoring the ambiguity. tcsh and yash will report an error. zsh and ksh will interpret it as an attempt to use one of their advanced directory-switching features and probably report an error.
If you're likely to use the same directory repeatedly, either putting the parent into
CDPATH or creating a shell variable
$FOO you can use in place of the long path is a better option. You can combine the shell variable with
** expansion to save more typing if you're using it often.