Home

globstar

Globstar is a feature of the Bash shell that enables recursive pathname expansion using the double asterisk pattern, **. When the Bash option globstar is enabled (for example, by running shopt -s globstar), patterns containing ** will recursively match files and directories across the entire path, not just the immediate directory.

With globstar enabled, ** matches zero or more directories. A common usage is to list or operate

Dotfiles and hidden paths require additional options. By default, Bash globbing does not match filenames that

Compatibility and scope. Globstar is a Bash feature introduced in Bash 4.0. It is not part of

Related considerations. Other globbing options that affect behavior include nullglob (allow pattern expansions to yield nothing

on
files
at
any
depth.
For
example,
echo
**/*.txt
lists
all
files
ending
in
.txt
in
the
current
directory
and
every
subdirectory.
Similarly,
echo
**/lib/*.so
can
locate
shared
library
files
in
any
subdirectory
under
the
current
location.
The
pattern
**/*
matches
any
file
or
directory
at
any
depth,
including
the
top
level
of
the
current
directory.
begin
with
a
dot.
To
include
hidden
files
and
directories,
enable
dotglob
(shopt
-s
dotglob)
in
combination
with
globstar,
or
explicitly
pattern
for
dotfiles.
the
POSIX
sh
specification,
and
behavior
may
differ
in
other
shells.
Some
shells,
such
as
Zsh,
provide
recursive
globbing
with
**
but
with
different
rules
and
options.
when
there
are
no
matches)
and
failglob
(treat
unmatched
patterns
as
errors).
Understanding
these
options
helps
predict
how
recursive
globs
behave
in
scripts
and
interactive
sessions.