<HTML><HEAD><TITLE>Tcl Built-In Commands - glob manual page</TITLE></HEAD><BODY> <DL> <DD><A HREF="glob.htm#M2" NAME="L368">NAME</A> <DL><DD>glob - Return names of files that match patterns</DL> <DD><A HREF="glob.htm#M3" NAME="L369">SYNOPSIS</A> <DL> <DD><B>glob </B>?<I>switches</I>? <I>pattern </I>?<I>pattern ...</I>? </DL> <DD><A HREF="glob.htm#M4" NAME="L370">DESCRIPTION</A> <DL> <DD><A HREF="glob.htm#M5" NAME="L371"><B>-nocomplain</B></A> <DD><A HREF="glob.htm#M6" NAME="L372"><B>--</B></A> </DL> <DL> <DD><A HREF="glob.htm#M7" NAME="L373"><B>?</B></A> <DD><A HREF="glob.htm#M8" NAME="L374"><B>*</B></A> <DD><A HREF="glob.htm#M9" NAME="L375"><B>[</B><I>chars</I><B>]</B></A> <DD><A HREF="glob.htm#M10" NAME="L376"><B>\</B><I>x</I></A> <DD><A HREF="glob.htm#M11" NAME="L377"><B>{</B><I>a</I><B>,</B><I>b</I><B>,</B><I>...</I>}</A> </DL> <DD><A HREF="glob.htm#M12" NAME="L378">PORTABILITY ISSUES</A> <DD><A HREF="glob.htm#M13" NAME="L379">KEYWORDS</A> </DL><HR> <H3><A NAME="M2">NAME</A></H3> glob - Return names of files that match patterns <H3><A NAME="M3">SYNOPSIS</A></H3> <B>glob </B>?<I>switches</I>? <I>pattern </I>?<I>pattern ...</I>?<BR> <H3><A NAME="M4">DESCRIPTION</A></H3> 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 <I>pattern</I> arguments. <P> If the initial arguments to <B>glob</B> start with <B>-</B> then they are treated as switches. The following switches are currently supported: <P> <DL> <P><DT><A NAME="M5"><B>-nocomplain</B></A><DD> Allows an empty list to be returned without error; without this switch an error is returned if the result list would be empty. <P><DT><A NAME="M6"><B>--</B></A><DD> Marks the end of switches. The argument following this one will be treated as a <I>pattern</I> even if it starts with a <B>-</B>. <P></DL> <P> The <I>pattern</I> arguments may contain any of the following special characters: <P> <DL> <P><DT><A NAME="M7"><B>?</B></A><DD> Matches any single character. <P><DT><A NAME="M8"><B>*</B></A><DD> Matches any sequence of zero or more characters. <P><DT><A NAME="M9"><B>[</B><I>chars</I><B>]</B></A><DD> Matches any single character in <I>chars</I>. If <I>chars</I> contains a sequence of the form <I>a</I><B>-</B><I>b</I> then any character between <I>a</I> and <I>b</I> (inclusive) will match. <P><DT><A NAME="M10"><B>\</B><I>x</I></A><DD> Matches the character <I>x</I>. <P><DT><A NAME="M11"><B>{</B><I>a</I><B>,</B><I>b</I><B>,</B><I>...</I>}</A><DD> Matches any of the strings <I>a</I>, <I>b</I>, etc. <P></DL> <P> As with csh, a ``.'' at the beginning of a file's name or just after a ``/'' must be matched explicitly or with a {} construct. In addition, all ``/'' characters must be matched explicitly. <P> If the first character in a <I>pattern</I> 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. <P> The <B>glob</B> command differs from csh globbing in two ways. First, it does not sort its result list (use the <B><A HREF="../TclCmd/lsort.htm">lsort</A></B> command if you want the list sorted). Second, <B>glob</B> only returns the names of files that actually exist; in csh no check for existence is made unless a pattern contains a ?, *, or [] construct. <H3><A NAME="M12">PORTABILITY ISSUES</A></H3> Unlike other Tcl commands that will accept both network and native style names (see the <B><A HREF="../TclCmd/filename.htm">filename</A></B> manual entry for details on how native and network names are specified), the <B>glob</B> command only accepts native names. Also, for Windows UNC names, the servername and sharename components of the path may not contain ?, *, or [] constructs. <H3><A NAME="M13">KEYWORDS</A></H3> <A href="../Keywords/E.htm#exist">exist</A>, <A href="../Keywords/F.htm#file">file</A>, <A href="../Keywords/G.htm#glob">glob</A>, <A href="../Keywords/P.htm#pattern">pattern</A> <HR><PRE> <A HREF="../copyright.htm">Copyright</A> © 1993 The Regents of the University of California. <A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> </BODY></HTML>