Negated Globs With extglob
Use !(pattern) and @(a|b) extended patterns to filter filenames.
Run shopt -s extglob then ls !(*.log) to list everything except log files.
01Command
Command
$ shopt -s extglob; ls !(*.log)02What it does
Extended globbing adds negated and grouped patterns to ordinary globs, so filtering a directory by extension needs no pipeline. It is a precise, shell-native way to select files for batch operations, something a file dialog cannot express.
03Risk
!Warning: extglob must be enabled before use and is incompatible with other pattern options in some shells.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- bash.1.en.html manual pageEvidence: The bash manual page documents extglob patterns.
Last verified: 2026-10-13 · Category: Developer