bash:globs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
bash:globs [2021/02/04 09:34] – [Glob Star - globstar] peter | bash:globs [2021/02/04 09:43] (current) – [Glob Star - globstar] peter | ||
---|---|---|---|
Line 434: | Line 434: | ||
</ | </ | ||
- | Just like '*', '**' followed by a '/' | + | <WRAP info> |
+ | **NOTE:** To disable globstar use | ||
<code bash> | <code bash> | ||
- | $ files=(**/) | + | shopt -u globstar |
- | # finds all subdirectories | + | </ |
- | $ files=(. **/) | + | See: **help shopt** for details. |
- | # finds all subdirectories, | + | </ |
- | # corresponds | + | |
+ | |||
+ | ---- | ||
+ | |||
+ | Assume you have a folder structure: | ||
+ | |||
+ | < | ||
+ | . | ||
+ | ├── bar | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | └── fnord.txt | ||
+ | </ | ||
+ | |||
+ | Then **ls** with single star **< | ||
+ | |||
+ | <code bash> | ||
+ | ls *.txt | ||
+ | fnord.txt | ||
+ | </ | ||
+ | |||
+ | The double star operator **< | ||
+ | |||
+ | <code bash> | ||
+ | ls **/*.txt | ||
+ | bar/ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | files=(**/ | ||
+ | # Finds all subdirectories. | ||
+ | |||
+ | files=(. **/) | ||
+ | # Finds all subdirectories, | ||
+ | # Corresponds | ||
</ | </ | ||
bash/globs.1612431289.txt.gz · Last modified: 2021/02/04 09:34 by peter