User Tools

Site Tools


bash:globs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
bash:globs [2021/02/04 09:37] – [Glob Star - globstar] peterbash:globs [2021/02/04 09:43] (current) – [Glob Star - globstar] peter
Line 433: Line 433:
 # Caveat: **.c will not work, as it expands to *.c/*.c/… # Caveat: **.c will not work, as it expands to *.c/*.c/…
 </code> </code>
 +
 +<WRAP info>
 +**NOTE:**  To disable globstar use
 +
 +<code bash>
 +shopt -u globstar
 +</code>
 +
 +See:  **help shopt** for details.
 +</WRAP>
 +
 +
 +----
 +
 +Assume you have a folder structure:
 +
 +<code>
 +.
 +├── bar
 +│   ├── foo
 +│   │   └── baz
 +│   │       └── hurz
 +│   │           └── lolz
 +│   │               └── hello.txt
 +│   └── poit.txt
 +└── fnord.txt
 +</code>
 +
 +Then **ls** with single star **<nowiki>*</nowiki>** would list:
 +
 +<code bash>
 +ls *.txt
 +fnord.txt
 +</code>
 +
 +The double star operator **<nowiki>**</nowiki>** will work on the subfolders.  The output will look like:
 +
 +<code bash>
 +ls **/*.txt
 +bar/foo/baz/hurz/lolz/hello.txt  bar/poit.txt  fnord.txt
 +</code>
 +
 +----
  
 <WRAP info> <WRAP info>
bash/globs.1612431422.txt.gz · Last modified: 2021/02/04 09:37 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki