165 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			165 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <HTML><HEAD><TITLE>Tcl Built-In Commands - glob manual page</TITLE></HEAD><BODY>
 | |
| <DL>
 | |
| <DD><A HREF="glob.htm#M2" NAME="L431">NAME</A>
 | |
| <DL><DD>glob - Return names of files that match patterns</DL>
 | |
| <DD><A HREF="glob.htm#M3" NAME="L432">SYNOPSIS</A>
 | |
| <DL>
 | |
| <DD><B>glob </B>?<I>switches</I>? <I>pattern </I>?<I>pattern ...</I>?
 | |
| </DL>
 | |
| <DD><A HREF="glob.htm#M4" NAME="L433">DESCRIPTION</A>
 | |
| <DL>
 | |
| <DD><A HREF="glob.htm#M5" NAME="L434"><B>-directory</B> <I>directory</I></A>
 | |
| <DD><A HREF="glob.htm#M6" NAME="L435"><B>-join</B></A>
 | |
| <DD><A HREF="glob.htm#M7" NAME="L436"><B>-nocomplain</B></A>
 | |
| <DD><A HREF="glob.htm#M8" NAME="L437"><B>-path</B> <I>pathPrefix</I></A>
 | |
| <DD><A HREF="glob.htm#M9" NAME="L438"><B>-types</B> <I>typeList</I></A>
 | |
| <DD><A HREF="glob.htm#M10" NAME="L439"><B>- -</B></A>
 | |
| </DL>
 | |
| <DL>
 | |
| <DD><A HREF="glob.htm#M11" NAME="L440"><B>?</B></A>
 | |
| <DD><A HREF="glob.htm#M12" NAME="L441"><B>*</B></A>
 | |
| <DD><A HREF="glob.htm#M13" NAME="L442"><B>[</B><I>chars</I><B>]</B></A>
 | |
| <DD><A HREF="glob.htm#M14" NAME="L443"><B>\</B><I>x</I></A>
 | |
| <DD><A HREF="glob.htm#M15" NAME="L444"><B>{</B><I>a</I><B>,</B><I>b</I><B>,</B><I>...</I>}</A>
 | |
| </DL>
 | |
| <DD><A HREF="glob.htm#M16" NAME="L445">PORTABILITY ISSUES</A>
 | |
| <DL>
 | |
| <DD><A HREF="glob.htm#M17" NAME="L446"><B>Windows</B></A>
 | |
| <DD><A HREF="glob.htm#M18" NAME="L447"><B>Macintosh</B></A>
 | |
| </DL>
 | |
| <DD><A HREF="glob.htm#M19" NAME="L448">SEE ALSO</A>
 | |
| <DD><A HREF="glob.htm#M20" NAME="L449">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>-directory</B> <I>directory</I></A><DD>
 | |
| Search for files which match the given patterns starting in the given
 | |
| <I>directory</I>.  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
 | |
| <B>-path</B>.
 | |
| <P><DT><A NAME="M6"><B>-join</B></A><DD>
 | |
| The remaining pattern arguments are treated as a single pattern
 | |
| obtained by joining the arguments with directory separators.
 | |
| <P><DT><A NAME="M7"><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="M8"><B>-path</B> <I>pathPrefix</I></A><DD>
 | |
| Search for files with the given <I>pathPrefix</I> where the rest of the name
 | |
| matches the given patterns.  This allows searching for files with names
 | |
| similar to a given file even when the names contain glob-sensitive
 | |
| characters.  This option may not be used in conjunction with
 | |
| <B>-directory</B>.
 | |
| <P><DT><A NAME="M9"><B>-types</B> <I>typeList</I></A><DD>
 | |
| Only list files or directories which match <I>typeList</I>, where the items
 | |
| in the list have two forms.  The first form is like the -type option of
 | |
| the Unix find command:
 | |
| <I>b</I> (block special file),
 | |
| <I>c</I> (character special file),
 | |
| <I>d</I> (directory),
 | |
| <I>f</I> (plain file),
 | |
| <I>l</I> (symbolic link),
 | |
| <I>p</I> (named pipe),
 | |
| or <I>s</I> (socket), where multiple types may be specified in the list.
 | |
| <B>Glob</B> will return all files which match at least one of the types given.
 | |
| <P>
 | |
| The second form specifies types where all the types given must match.
 | |
| These are <I>r</I>, <I>w</I>, <I>x</I> as file permissions, and
 | |
| <I>readonly</I>, <I>hidden</I> 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. <B><A HREF="../TclCmd/text.htm">TEXT</A></B>).  Items which are of the form <I>{macintosh type XXXX}</I>
 | |
| or <I>{macintosh creator XXXX}</I> will match types or creators
 | |
| respectively.  Unrecognised types, or specifications of multiple MacOS
 | |
| types/creators will signal an error.
 | |
| <P>
 | |
| The two forms may be mixed, so <B>-types {d f r w}</B> will find all
 | |
| regular files OR directories that have both read AND write permissions.
 | |
| The following are equivalent:
 | |
| <PRE><B>glob -type d *</B>
 | |
| <B>glob */</B></PRE>
 | |
| except that the first case doesn't return the trailing ``/'' and
 | |
| is more platform independent.
 | |
| <P><DT><A NAME="M10"><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="M11"><B>?</B></A><DD>
 | |
| Matches any single character.
 | |
| <P><DT><A NAME="M12"><B>*</B></A><DD>
 | |
| Matches any sequence of zero or more characters.
 | |
| <P><DT><A NAME="M13"><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="M14"><B>\</B><I>x</I></A><DD>
 | |
| Matches the character <I>x</I>.
 | |
| <P><DT><A NAME="M15"><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="../TkCmd/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="M16">PORTABILITY ISSUES</A></H3>
 | |
| Unlike other Tcl commands that will accept both network and native
 | |
| style names (see the <B><A HREF="../TkCmd/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.  
 | |
| <P>
 | |
| <DL>
 | |
| <P><DT><A NAME="M17"><B>Windows</B></A><DD>
 | |
| For Windows UNC names, the servername and sharename components of the path
 | |
| may not contain ?, *, or [] constructs.  On Windows NT, if <I>pattern</I> is
 | |
| of the form ``<B>~</B><I>username</I><B>@</B><I>domain</I>'' 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, <B>glob</B> accepts patterns
 | |
| like ``.../'' and ``..../'' for successively higher up parent directories.
 | |
| <P><DT><A NAME="M18"><B>Macintosh</B></A><DD>
 | |
| When using the options, <B>-dir</B>, <B>-join</B> or <B>-path</B>, 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 ``:''.
 | |
| 
 | |
| <P></DL>
 | |
| <H3><A NAME="M19">SEE ALSO</A></H3>
 | |
| <B><A HREF="../TkCmd/file.htm">file</A></B>
 | |
| <H3><A NAME="M20">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>
 | 
