1mNAME0m
       glob - Return names of files that match patterns

1mSYNOPSIS0m
       1mglob 22m?4mswitches24m? 4mpattern24m ?4mpattern24m 4m...24m?


1mDESCRIPTION0m
       This  command  performs  file name ``globbing'' in a fashion similar to
       the csh shell.  It returns a list of the files whose names match any of
       the 4mpattern24m arguments.

       If  the initial arguments to 1mglob 22mstart with 1m- 22mthen they are treated as
       switches.  The following switches are currently supported:

       1m-directory 4m22mdirectory0m
              Search for files which match the given patterns starting in  the
              given  4mdirectory24m.   This  allows  searching of directories whose
              name contains glob-sensitive  characters  without  the  need  to
              quote  such  characters explicitly.  This option may not be used
              in conjunction with 1m-path22m, which is used to allow searching  for
              complete file paths whose names may contain glob-sensitive char-
              acters.

       1m-join  22mThe remaining pattern arguments are treated as a single  pattern
              obtained by joining the arguments with directory separators.

       1m-nocomplain0m
              Allows an empty list to be returned without error;  without this
              switch an error is returned if the result list would be empty.

       1m-path 4m22mpathPrefix0m
              Search for files with the given 4mpathPrefix24m where the rest of the
              name  matches  the  given  patterns.   This allows searching for
              files with names similar to a given file (as opposed to a direc-
              tory)  even  when  the  names contain glob-sensitive characters.
              This option may not be used in conjunction with 1m-directory22m.  For
              example, to find all files with the same root name as $path, but
              differing extensions, you should use 1mglob -path  [file  rootname0m
              1m$path]  .* 22mwhich will work even if $path contains numerous glob-
              sensitive characters.

       1m-tails 22mOnly return the part of each file found which follows  the  last
              directory  named  in any 1m-directory 22mor 1m-path 22mpath specification.
              Thus 1mglob -tails -directory $dir *  22mis  equivalent  to  1mset  pwd0m
              1m[pwd]  ;  cd  $dir ; glob *; cd $pwd22m.  For 1m-path 22mspecifications,
              the returned names will include the last path segment,  so  1mglob0m
              1m-tails  -path  [file  rootname  ~/foo.tex] .*  22mwill return paths
              like 1mfoo.aux foo.bib foo.tex 22metc.

       1m-types 4m22mtypeList0m
              Only list files or directories which match 4mtypeList24m,  where  the
              items  in  the  list have two forms.  The first form is like the
              -type option of the Unix find command: 4mb24m (block special file), 4mc0m
              (character special file), 4md24m (directory), 4mf24m (plain file), 4ml24m (sym-
              bolic link), 4mp24m (named pipe), or 4ms24m (socket), where multiple types
              may  be specified in the list.  1mGlob 22mwill return all files which
              match at least one of the types given.  Note that symbolic links
              will  be returned both if 1m-types l 22mis given, or if the target of
              a link matches the requested type.  So, a link  to  a  directory
              will be returned if 1m-types d 22mwas specified.

              The  second  form specifies types where all the types given must
              match.  These are 4mr24m, 4mw24m, 4mx24m as  file  permissions,  and  4mreadonly24m,
              4mhidden24m  as  special  permission  cases.  On the Macintosh, MacOS
              types and creators are also supported, where any item  which  is
              four  characters long is assumed to be a MacOS type (e.g. 1mTEXT22m).
              Items which are of the form 4m{macintosh24m 4mtype24m 4mXXXX}24m or  4m{macintosh0m
              4mcreator24m 4mXXXX}24m will match types or creators respectively.  Unrec-
              ognized types, or specifications of  multiple  MacOS  types/cre-
              ators will signal an error.

              The  two  forms  may be mixed, so 1m-types {d f r w} 22mwill find all
              regular files OR directories that have both read AND write  per-
              missions.  The following are equivalent:
                            1mglob -type d *0m
                            1mglob */0m
              except that the first case doesn't return the trailing ``/'' and
              is more platform independent.

       1m--     22mMarks the end of switches.  The argument following this one will
              be treated as a 4mpattern24m even if it starts with a 1m-22m.

       The  4mpattern24m arguments may contain any of the following special charac-
       ters:

       1m?         22mMatches any single character.

       1m*         22mMatches any sequence of zero or more characters.

       1m[4m22mchars24m1m]   22mMatches any single character in 4mchars24m.  If 4mchars24m  contains  a
                 sequence  of  the form 4ma24m1m-4m22mb24m then any character between 4ma24m and 4mb0m
                 (inclusive) will match.

       1m\4m22mx24m        Matches the character 4mx24m.

       1m{4m22ma24m1m,4m22mb24m1m,4m22m...24m} Matches any of the strings 4ma24m, 4mb24m, etc.

       On Unix, as with csh, a ``.'' at the beginning of a file's name or just
       after a ``/'' must be matched explicitly or with a {} construct, unless
       the ``-types hidden'' flag is given (since ``.'' at the beginning of  a
       file's  name  indicates  that it is hidden).  On other platforms, files
       beginning with a ``.'' are handled no differently to any others, except
       the  special directories ``.'' and ``..'' which must be matched explic-
       itly (this is to avoid a recursive pattern like ``glob -join * * *  *''
       from  recursing  up the directory hierarchy as well as down).  In addi-
       tion, all ``/'' characters must be matched explicitly.

       If the first character in a 4mpattern24m is ``~'' then it refers to the home
       directory  for  the user whose name follows the ``~''.  If the ``~'' is
       followed immediately by ``/'' then the value of  the  HOME  environment
       variable is used.

       The 1mglob 22mcommand differs from csh globbing in two ways.  First, it does
       not sort its result list (use the 1mlsort 22mcommand if you  want  the  list
       sorted).   Second,  1mglob  22monly returns the names of files that actually
       exist;  in csh no check for existence is made unless a pattern contains
       a ?, *, or [] construct.

       When the 1mglob 22mcommand returns relative paths whose filenames start with
       a tilde ``~'' (for example through 1mglob * 22mor 1mglob -tails22m, the  returned
       list  will  not  quote  the tilde with ``./''.  This means care must be
       taken if those names are later to be used with 1mfile join22m, to avoid them
       being  interpreted  as  absolute  paths pointing to a given user's home
       directory.

1mPORTABILITY ISSUES0m
       Unlike other Tcl commands that will  accept  both  network  and  native
       style  names  (see  the 1mfilename 22mmanual entry for details on how native
       and network names are specified), the 1mglob 22mcommand only accepts  native
       names.

       1mWindows0m
              For  Windows  UNC names, the servername and sharename components
              of the path may not contain ?, *, or [] constructs.  On  Windows
              NT,  if 4mpattern24m is of the form ``1m~4m22musername24m1m@4m22mdomain24m'' it refers to
              the home directory of the user whose account information resides
              on  the  specified  NT  domain  server.  Otherwise, user account
              information is obtained from the local computer.  On Windows  95
              and  98,  1mglob  22maccepts patterns like ``.../'' and ``..../'' for
              successively higher up parent directories.

              Since the backslash character has a special meaning to the  glob
              command,  glob patterns containing Windows style path separators
              need special care. The  pattern  4mC:\\foo\\*24m  is  interpreted  as
              4mC:\foo\*24m  where 4m\f24m will match the single character 4mf24m and 4m\*24m will
              match the single character 4m*24m and will not be  interpreted  as  a
              wildcard  character.  One solution to this problem is to use the
              Unix style forward slash as  a  path  separator.  Windows  style
              paths can be converted to Unix style paths with the command 1mfile0m
              1mjoin $path 22m(or 1mfile normalize $path 22min Tcl 8.4).

       1mMacintosh0m
              When using the options, 1m-directory22m, 1m-join 22mor 1m-path22m, glob assumes
              the  directory  separator for the entire pattern is the standard
              ``:''.  When not using these options, glob examines each pattern
              argument and uses ``/'' unless the pattern contains a ``:''.

1mEXAMPLES0m
       Find all the Tcl files in the current directory:
              1mglob 22m*.tcl

       Find  all  the  Tcl files in the user's home directory, irrespective of
       what the current directory is:
              1mglob 22m-directory ~ *.tcl

       Find all subdirectories of the current directory:
              1mglob 22m-type d *

       Find all files whose name contains an "a", a "b" or the sequence "cde":
              1mglob 22m-type f *{a,b,cde}*


1mSEE ALSO0m
       file(n)


1mKEYWORDS0m
