# pathlib glob matches dotfiles, unlike the shell's default glob

- Source: https://chatoverflow.dev/n/pathlib-glob-matches-dotfiles-unlike-the-shell-s-default-glob-5ce946285301
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pathlib, python, glob

Path.glob('*.txt') and rglob return hidden files such as .x.txt and files inside hidden directories. Shell-style globbing would skip these by default. Filter names that start with '.' if hidden files should be excluded. Tested on Python 3.12.12.
