OSDN Git Service

Initial revision
[pf3gnuchains/sourceware.git] / tcl / doc / glob.n
1 '\"
2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\" 
8 '\" RCS: @(#) $Id$
9 '\" 
10 .so man.macros
11 .TH glob n 7.5 Tcl "Tcl Built-In Commands"
12 .BS
13 '\" Note:  do not modify the .SH NAME line immediately below!
14 .SH NAME
15 glob \- Return names of files that match patterns
16 .SH SYNOPSIS
17 \fBglob \fR?\fIswitches\fR? \fIpattern \fR?\fIpattern ...\fR?
18 .BE
19
20 .SH DESCRIPTION
21 .PP
22 This command performs file name ``globbing'' in a fashion similar to
23 the csh shell.  It returns a list of the files whose names match any
24 of the \fIpattern\fR arguments.
25 .LP
26 If the initial arguments to \fBglob\fR start with \fB\-\fR then
27 they are treated as switches.  The following switches are
28 currently supported:
29 .TP 15
30 \fB\-nocomplain\fR
31 Allows an empty list to be returned without error;  without this
32 switch an error is returned if the result list would be empty.
33 .TP 15
34 \fB\-\|\-\fR
35 Marks the end of switches.  The argument following this one will
36 be treated as a \fIpattern\fR even if it starts with a \fB\-\fR.
37 .PP
38 The \fIpattern\fR arguments may contain any of the following
39 special characters:
40 .TP 10
41 \fB?\fR
42 Matches any single character.
43 .TP 10
44 \fB*\fR
45 Matches any sequence of zero or more characters.
46 .TP 10
47 \fB[\fIchars\fB]\fR
48 Matches any single character in \fIchars\fR.  If \fIchars\fR
49 contains a sequence of the form \fIa\fB\-\fIb\fR then any
50 character between \fIa\fR and \fIb\fR (inclusive) will match.
51 .TP 10
52 \fB\e\fIx\fR
53 Matches the character \fIx\fR.
54 .TP 10
55 \fB{\fIa\fB,\fIb\fB,\fI...\fR}
56 Matches any of the strings \fIa\fR, \fIb\fR, etc.
57 .LP
58 As with csh, a  ``.'' at the beginning of a file's name or just
59 after a ``/'' must be matched explicitly or with a {} construct.
60 In addition, all ``/'' characters must be matched explicitly.
61 .LP
62 If the first character in a \fIpattern\fR is ``~'' then it refers
63 to the home directory for the user whose name follows the ``~''.
64 If the ``~'' is followed immediately by ``/'' then the value of
65 the HOME environment variable is used.
66 .LP
67 The \fBglob\fR command differs from csh globbing in two ways.
68 First, it does not sort its result list (use the \fBlsort\fR
69 command if you want the list sorted).
70 Second, \fBglob\fR only returns the names of files that actually
71 exist;  in csh no check for existence is made unless a pattern
72 contains a ?, *, or [] construct.
73
74 .SH PORTABILITY ISSUES
75 .PP
76 Unlike other Tcl commands that will accept both network and native
77 style names (see the \fBfilename\fR manual entry for details on how
78 native and network names are specified), the \fBglob\fR command only
79 accepts native names.  Also, for Windows UNC names, the servername and
80 sharename components of the path may not contain ?, *, or []
81 constructs. 
82
83 .SH KEYWORDS
84 exist, file, glob, pattern