Path.wildcard

You're seeing just the function wildcard, go back to Path module for more information.
Link to this function

wildcard(glob, opts \\ [])

View Source

Specs

wildcard(t(), keyword()) :: [binary()]

Traverses paths according to the given glob expression and returns a list of matches.

The wildcard looks like an ordinary path, except that the following "wildcard characters" are interpreted in a special way:

  • ? - matches one character.

  • * - matches any number of characters up to the end of the filename, the next dot, or the next slash.

  • ** - two adjacent *'s used as a single pattern will match all files and zero or more directories and subdirectories.

  • [char1,char2,...] - matches any of the characters listed; two characters separated by a hyphen will match a range of characters. Do not add spaces before and after the comma as it would then match paths containing the space character itself.

  • {item1,item2,...} - matches one of the alternatives. Do not add spaces before and after the comma as it would then match paths containing the space character itself.

Other characters represent themselves. Only paths that have exactly the same character in the same position will match. Note that matching is case-sensitive: "a" will not match "A".

Directory separators must always be written as /, even on Windows. You may call Path.expand/1 to normalize the path before invoking this function.

By default, the patterns * and ? do not match files starting with a dot .. See the :match_dot option in the "Options" section below.

Options

  • :match_dot - (boolean) if false, the special wildcard characters * and ? will not match files starting with a dot (.). If true, files starting with a . will not be treated specially. Defaults to false.

Examples

Imagine you have a directory called projects with three Elixir projects inside of it: elixir, ex_doc, and plug. You can find all .beam files inside the ebin directory of each project as follows:

Path.wildcard("projects/*/ebin/**/*.beam")

If you want to search for both .beam and .app files, you could do:

Path.wildcard("projects/*/ebin/**/*.{beam,app}")