Home Explore Blog CI



nushell

commands/docs/glob.md
ead1dc3cd5e1343f355f1bfe2850b4ae34ee1fa43ef30d1c0000000300000a7d
---
title: glob
categories: |
  filesystem
version: 0.104.0
filesystem: |
  Creates a list of files and/or folders based on the glob pattern provided.
usage: |
  Creates a list of files and/or folders based on the glob pattern provided.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `glob` for [filesystem](/commands/categories/filesystem.md)

<div class='command-title'>Creates a list of files and&amp;#x2f;or folders based on the glob pattern provided.</div>

## Signature

```> glob {flags} (glob)```

## Flags

 -  `--depth, -d {int}`: directory depth to search
 -  `--no-dir, -D`: Whether to filter out directories from the returned paths
 -  `--no-file, -F`: Whether to filter out files from the returned paths
 -  `--no-symlink, -S`: Whether to filter out symlinks from the returned paths
 -  `--follow-symlinks, -l`: Whether to follow symbolic links to their targets
 -  `--exclude, -e {list<string>}`: Patterns to exclude from the search: `glob` will not walk the inside of directories matching the excluded patterns.

## Parameters

 -  `glob`: The glob expression.


## Input/output types:

| input   | output       |
| ------- | ------------ |
| nothing | list\<string\> |
## Examples

Search for *.rs files
```nu
> glob *.rs

```

Search for *.rs and *.toml files recursively up to 2 folders deep
```nu
> glob **/*.{rs,toml} --depth 2

```

Search for files and folders that begin with uppercase C or lowercase c
```nu
> glob "[Cc]*"

```

Search for files and folders like abc or xyz substituting a character for ?
```nu
> glob "{a?c,x?z}"

```

A case-insensitive search for files and folders that begin with c
```nu
> glob "(?i)c*"

```

Search for files for folders that do not begin with c, C, b, M, or s
```nu
> glob "[!cCbMs]*"

```

Search for files or folders with 3 a's in a row in the name
```nu
> glob <a*:3>

```

Search for files or folders with only a, b, c, or d in the file name between 1 and 10 times
```nu
> glob <[a-d]:1,10>

```

Search for folders that begin with an uppercase ASCII letter, ignoring files and symlinks
```nu
> glob "[A-Z]*" --no-file --no-symlink

```

Search for files named tsconfig.json that are not in node_modules directories
```nu
> glob **/tsconfig.json --exclude [**/node_modules/**]

```

Search for all files that are not in the target nor .git directories
```nu
> glob **/* --exclude [**/target/** **/.git/** */]

```

Search for files following symbolic links to their targets
```nu
> glob "**/*.txt" --follow-symlinks

```

## Notes
For more glob pattern help, please refer to https://docs.rs/crate/wax/latest

Chunks
63986ec8 (1st chunk of `commands/docs/glob.md`)
Title: glob
Summary
The `glob` command creates a list of files and/or folders based on the provided glob pattern. It supports flags for controlling search depth, filtering by file type (files, directories, symlinks), following symlinks, and excluding patterns. Examples demonstrate searching for specific file types, recursive searches, case-insensitive searches, and excluding directories.