Daniel Roy Greenfeld

Daniel Roy Greenfeld

About | Articles | Books | Jobs | News | Tags

TIL: Finding and ignoring files with Glob

Glob is a really handy tool for finding filepaths. It resembles regular expressions but the syntax is different. Finding matches is easy:

# finds python files in the current working directory
*.py
# finds all the nested python files.
**/*.py

What I didn't know until today is how to exclude files. That's done through the use of the ! operator. So the inverse of the above is:

# finds anything but python files in the current working directory
*.[!py]*
# finds anything but python files in the nested directory 
- **/*.[!py]*


Tags: TIL
← Back to home