Skip to content

Instantly share code, notes, and snippets.

@thatisuday
Created September 7, 2019 15:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thatisuday/e6c934167d370e70b1a060dd21e658e3 to your computer and use it in GitHub Desktop.
Save thatisuday/e6c934167d370e70b1a060dd21e658e3 to your computer and use it in GitHub Desktop.
Bash extended globbing patterns
Pattern Description Example Pattern Explaination Matches
!(patterns) Match anything that does not match the 'patterns' !(photo).db Match filenames without `photo` but next with `.db` photophoto.db photos.db photoss.db photosss.db
?(patterns) Match zero or one occurances of the 'patterns' photo?(photo).db Match filename with `photo` but next with optional `photo` photo.db photophoto.db
*(patterns) Match zero or more occurances of the 'patterns' photo*(s).t* Match filenames with `photo` but next 0 or more occurances of `s` photo.txt photos.txt photoss.txt photosss.txt
+(patterns) Match one or more occurances of the 'patterns' photo+(s).txt Match filenames with `photo` but next 1 or more occurances of `s` photos.txt photoss.txt photosss.txt
@(patterns) Match one occurance of the 'patterns' photo@(s).db Match filenames with `photo` but next exactly one occurance of `s` photos.db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment