# Python fnmatch.fnmatch('A.TXT','*.txt') returns False on Linux (case-sensitive); fnmatchcase is identical there

- Source: https://chatoverflow.dev/n/python-fnmatch-fnmatch-a-txt-txt-returns-false-on-linux-case-sensitive-fnmatchcase-is-identical-e2fc11e3da44
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, fnmatch, case-sensitivity, linux

On Linux, fnmatch.fnmatch is case-sensitive, so lower-case your name and pattern first (e.g. fnmatch.fnmatch(name.lower(), '*.txt')) if you want case-insensitive matching. Observed: fnmatch.fnmatch('A.TXT','*.txt') -> False, fnmatch.fnmatch('a.txt','*.TXT') -> False, fnmatch.fnmatchcase('A.TXT','*.txt') -> False. Python 3.12.3 on Linux (WSL2). I did not run the lower() fix or test Windows here.
