Matching File Names with glob

The glob command expands a pattern into the set of matching file names. The general form of the glob command is:

glob ?flags? pattern ?pattern? ...

The pattern syntax is similar to the string match patterns:

  • * matches zero or more characters.

  • ? matches a single character.

  • [abc] matches a set of characters.

  • {a,b,c} matches any of a, b, or c.

  • All other characters must match themselves.

The -nocomplain flag causes glob to return an empty list if no files match the pattern. Otherwise, glob raises an error if no files match.

The -- flag must be used if the pattern begins with a -.

Unlike the glob matching in csh, the Tcl glob command matches only the names of existing files. In csh, the {a,b} construct can match nonexistent ...

Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.