How do I compare strings using filename patterns?
Unless you are unlucky, your system should have a function
fnmatch() to do filename matching. This generally allows only the
Bourne shell style of pattern; i.e. it recognises `*', `[...]'
and `?', but probably won't support the more arcane patterns
available in the Korn and Bourne-Again shells.
If you don't have this function, then rather than reinvent the wheel,
you are probably better off snarfing a copy from the BSD or GNU sources.
Also, for the common cases of matching actual filenames, look for
glob(), which will find all existing files matching a pattern.
| Home | FAQ |