To answer the specific question asked here about what the given patterns mean, let's assume a couple of things:
globstar
pattern matching is used, which makes **
(double asterisk) pattern matching work. If you're using this in Linux, you can work with the globstar
option using shopt
(shell options) like this:
shopt globstar = shows if the globstar option is on or off
shopt -s globstar = enables the globstar option for the current session
shopt -u globstar = disables the globstar option for the current session
globstar
pattern matching is normally disabled by default, but you can edit your .bashrc
file or the like if you want it to be enabled by default instead.
path
is a subdirectory within the current directory
- we're using the patterns below with the
ls
command:
path = all of the contents of the 'path' directory, but no subdirectories
path/ = the same as 'ls path'
path/* = show all items in the 'path' directory and in any immediate subdirectories
path/*.* = the same 'path/*', but only for items that have a '.' in the name
path/** = show all items in the 'path' directory and in all of its subdirectories, showing full paths first then individual directory contents
path/**/ = the same as 'ls path/**', but doesn't show full paths
path/**/* = the same as 'ls path/**', but without showing the items within the 'path' directory
path/**/*.* = the same as 'ls path/**/*', but only for items that have a '.' somewhere in the item's name
Note: "Items" includes both files and directories.
Here are a few other patterns explained:
path/*.txt = all items that end with '.txt' within the 'path' directory
path/**.txt = the same as 'ls path/*.txt'
path/*/*.txt = all items that end with '.txt' that are within an immediate subdirectory of the 'path' directory
path/**/*.txt = all items that end with '.txt' within the 'path' directory and all of its subdirectories
Thus, if you want to find all of the *.txt
files in a directory or any of its subdirectories, using ls **/*.txt
makes that pretty easy.
However, keep in mind that there are other options which may affect how the above works and not all systems have implemented glob matching the exact same way, so the above may not hold true for all cases.
For other glob patterns and information about them, here are some other handy resources:
Enjoy!