Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use the codebuild-glob-search CLI command

Focus mode

On this page

Use the codebuild-glob-search CLI command - AWS CodeBuild

AWS CodeBuild provides a built-in CLI tool called codebuild-glob-search that allows you to search for files in your working directory based on one or more glob patterns. This tool can be particularly useful when you want to run tests on specific files or directories within your project.

Usage

The codebuild-glob-search CLI has the following usage syntax:

codebuild-glob-search <glob_pattern1> [<glob_pattern2> ...]
  • <glob_pattern1>, <glob_pattern2>, etc.: One or more glob patterns to match against the files in your working directory.

  • *: Matches any sequence of characters (excluding path separators).

  • **: Matches any sequence of characters (including path separators).

Note

Ensure that the glob string has quotes. To check the results of pattern-matching, use the echo command.

version: 0.2 phases: build: commands: - echo $(codebuild-glob-search '**/__tests__/*.js') - codebuild-glob-search '**/__tests__/*.js' | xargs -n 1 echo

Output

The CLI will output a newline-separated list of file paths that match the provided glob patterns. The file paths returned will be relative to the working directory.

If no files are found matching the provided patterns, the CLI will output a message indicating that no files were found.

Note that directories found due to any given pattern will be excluded from the search results.

Example

If you want to search only for files inside the tests directory and its subdirectories with a .js extension, you can use the following command with the codebuild-glob-search CLI:

codebuild-glob-search '**/__tests__/*.js'

This command will search for all files with a .js extension inside the __tests__directory and its subdirectories, as denoted by the pattern.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.