I think you have only to activate the bash globstar
option, because it is not active by default in Ubuntu, as explained in the following.
The expression /path/to/music/directory/{**/,}*
contain two expansion constructs: has a brace expansion and next a pathname expansion.
Brace expansion
Brace expansion is best explained with an example:
$ printf '%s\n' before-{a,bb,1,22}-after
before-a-after
before-bb-after
before-1-after
before-22-after
(I've used, here and in the following, the command printf '%s\n' item1 item2 etc..
that is like echo
but prints each element on a new line)
You see that each comma separated element in braces results in an expanded element.
The original example, containing in braces the elements **/
and an empty element, expands to
$ printf '%s\n' /path/to/music/directory/{**/,}*
/path/to/music/directory/**/*
/path/to/music/directory/*
Globstar
Turn now to the bash glob **
, that is mentioned two times in the bash manual page, both in relation to the shell option globstar
, and the meaning is as follow:
the pattern ** used in a pathname expansion context will match a files and zero or more directories and subdirectories.
This shell option is not active by default in Ubuntu:
$ shopt globstar
globstar off
You can activate it with
shopt -s globstar
(use shopt -u globstar
to deactivate it).
If we have the following directory structure:
$ find first/ | sort
first/
first/aaa
first/second
first/second/bbb01
first/second/bbb02
first/second/third
first/second/third/ccc1
first/second/third/ccc2
first/second/third/ccc3
we could have the following expansions:
$ printf '%s\n' first/**/a*
first/aaa
$ printf '%s\n' first/**/b*
first/second/bbb01
first/second/bbb02
$ printf '%s\n' first/**/c*
first/second/third/ccc1
first/second/third/ccc2
first/second/third/ccc3
so you can see that **
is able to expand to more than a pathname element.
When you do ls *
the *
is being expanded before it is passed to ls
. That is to say if we have three files (a
, b
and c
) in a directory ls *
is actually running ls a b c
.
When Bash can't expand, it passes through the raw string¹. That's why you see the wildcards in the error, along with a not found message. ls
tried to show the listing for a file literally called *.bash*
.
So why didn't that expand? Well by default globbing (what this wildcard expansion is called) won't return hidden files. You can change this with shopt -s dotglob
(that won't persist unless you stick it in your .bashrc
— it might be disabled by default for a good reason so be careful with it), here's a quick demo:
$ ls *.bash*
ls: cannot access *.bash*: No such file or directory
$ shopt -s dotglob
$ ls *.bash*
.bash_aliases .bash_history .bash_logout .bashrc .bashrc.save
The exception to this is —as you've already shown— when you've already explicitly stated the files will be hidden with a pattern like .bash*
. It simply overrides the default dotglob
setting:
$ shopt -u dotglob # unset dotglob
$ ls .bash*
.bash_aliases .bash_history .bash_logout .bashrc .bashrc.save
Anyway besides that quirk, I hope this helps you understand what's going on under the surface.
There are other shopt
flags that alter how globbing works: extglob
, failglob
, globstar
, nocaseglob
and nullglob
. They and a raft of other shopt
flags are documented as part of the Bash manual.
Similarly, the page on Pattern Matching should make for some good reading.
¹ Unless failglob
or nullglob
are set.
Best Answer
whereis
doesn't locate files, becausewhereis
command is not intended to be used for that.From
whereis
manpagewhereis - locate the binary, source, and manual page files for a command
For more information type
man whereis
in your terminal to refer theman
page. For finding a file you have to use commands likegrep
,find
,locate
, etc...