'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: glob.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: glob.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH glob 3tcl 8.3 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME glob \- 返回匹配模式的文件名 .SH "總覽 SYNOPSIS" \fBglob \fR?\fIswitches\fR? \fIpattern \fR?\fIpattern ...\fR? .BE .SH "描述 DESCRIPTION" .PP 這個命令用與 csh shell 類似的方式進行文件名的“通配符匹配”。它返回文件名匹配 \fIpattern\fR (模式)參數中的所有文件的一個列表。 .LP 如果給 \fBglob\fR 的初始參數以 \fB\-\fR 開始,則它們將被作爲選項來對待。當前支持下列選項開關: .VS 8.3 .TP \fB\-directory\fR \fIdirectory\fR 在這個給定的 \fIdirectory \fR(目錄)中開始查找匹配給定模式的文件。這允許查找名字中包含通配符敏感字符的目錄而不需要顯式的引用這些字符。這個選項不能與\fB\-path\fR 聯合使用。 .TP \fB\-join\fR 把通過剩餘的模式參數用目錄分隔符連接起來作爲一個單一的模式來對待。 .VE 8.3 .TP \fB\-nocomplain\fR 允許返回一個空列表而不是返回一個錯誤;要是沒有這個開關的話,如果結果列表爲空則返回一個錯誤。 .VS 8.3 .TP \fB\-path\fR \fIpathPrefix\fR 查找有給定的 \fIpathPrefix\fR (路徑前綴)的文件,名字中餘下的部分匹配給定模式。這個選項允許查找與一個給定文件有類似的名字的文件,包括名字中包含通配符敏感的字符的情況。這個選項不能與\fB-directory\fR 聯合使用。 .TP \fB\-types\fR \fItypeList\fR 只列出匹配 \fItypeList \fR(類型列表)的文件或目錄,在這個列表中的元素有兩種形式。第一種形式類似 Unix find 命令的 -type 選項: \fIb\fR (塊特殊文件 block special file), \fIc\fR (字符特殊文件 character special file), \fId\fR (目錄 directory), \fIf\fR (單純文件 plain file), \fIl\fR (符號連接 symbolic link), \fIp\fR (命名管道 named pipe), or \fIs\fR (套接口 socket), 在這個列表中可以指定多個類型。\fBGlob\fR 返回至少匹配一個類型的所有文件。 .RS .PP 對於第二種形式指定的類型,所有給出的類型都必須匹配。它們是作爲文件權限的 \fIr\fR、\fIw\fR、\fIx\fR和作爲特殊權限的實例的 \fIreadonly\fR、\fIhidden\fR。在 Macintosh 上,還支持 MacOS 類型和建立者,假定任何四個字符長的項目都是一個 MacOS 類型(例如 \fBTEXT\fR)。有\fI{macintosh type XXXX}\fR 或 \fI{macintosh creator XXXX} \fR形式的項目將分別的匹配類型或建立者。不可識別的類型,或多個 MacOS 類型/建立者指定將導致錯誤。 .PP 以混合兩種類型,所以 \fB-types {d f r w}\fR 將找到有讀\fB和\fR寫權限的正規文件\fB或\fR目錄。下列命令等價: .RS .CS \fBglob \-type d *\fR \fBglob */\fR .CE .RE 但第一種情況不返回尾部的 ``/'' 並且更加不依賴平臺。 .RE .VE 8.3 .TP \fB\-\|\-\fR 標誌着選項的結束。此後的參數即使以 \fB- \fR開始仍將被作爲\fIpattern\fR 對待。 .PP \fIpattern\fR 參數可以包含任意下列特殊字符: .TP 10 \fB?\fR 匹配任何單一字符。 .TP 10 \fB*\fR 匹配零個或多個字符的任何序列。 .TP 10 \fB[\fIchars\fB]\fR 匹配在 \fIchars \fR中的任何單一字符。如果 \fIchars\fR 包含 \fIa\fR\fB-\fR\fIb\fR 形式的一個序列則匹配在 \fIa\fR 和 \fIb\fR 之間(包括它們在內)的任何字符。 .TP 10 \fB\e\fIx\fR 匹配字符 \fIx\fR。 .TP 10 \fB{\fIa\fB,\fIb\fB,\fI...\fR} 匹配字符串 \fIa\fR、\fIb\fR\fI \fR等中的任何一個。 .LP 與 csh 一樣, 在一個文件的名字的開始處或緊隨“/”之後的那個“.”必須被顯式的(explicit)匹配或與一個 {} 構造(construct)相匹配。額外的,所有“/”字符必須顯式的匹配。 .LP 如果在一個 \fIpattern\fR中的第一個是“~”,則它參照一個用戶的主目錄,這個用戶的名字緊隨在“~”之後。如果 “~”的後面緊隨着一個“/”,則使用 HOME 環境變量的值。 .LP \fBglob\fR與 csh globbing 在兩個方面有區別。首先,它不排序它的結果列表(如果你想排序的話使用 \fBlsort\fR 命令)。其次,\fBglob\fR 只返回實際存在的文件的名字;在 csh 中除非一個模式包含一個 ?、*、或 [] 構造,否則不檢查文件是否存在。 .SH "移植要點 PORTABILITY ISSUES" .PP 不象其他 Tcl 命令那樣接受網絡和本地式樣的兩種名字(關於如何指定本地和網絡名字的詳情參見 \fBfilename\fR手冊條目),而 \fBglob\fR 命令只接受本地名字。 .TP \fBWindows\fR . 對於 Windows UNC 名字,路徑組成部分中的服務器名和共享名不能包含?、*、或 [] 構造。在 Windows NT 上,如果 \fIpattern\fR 有 ``\fB~\fIusername\fB@\fIdomain\fR'' 的形式,則它參照一個用戶的主目錄,這個用戶的帳號信息駐留在指定 NT 域控制器上。否則,從本地計算機獲取用戶帳號信息。在 Windows 95 和 98 上,\fBglob\fR 接受象“.../” 和 “..../”這樣的模式,用於連續的更上層的父目錄。 .TP \fBMacintosh\fR . 在使用了選項 \fB\-dir\fR、\fB\-join\fR 或 \fB\-path \fR的時候,glob 假定給整個模式的目錄分隔符是標準的“:”。在不使用這些選項的時候,glob 檢查每個模式參數,除非這個模式包含一個“:”,否則使用“/”。 .SH "參見 SEE ALSO" file(n) .SH "關鍵字 KEYWORDS" exist, file, glob, pattern .SH "[中文版維護人]" .B 寒蟬退士 .SH "[中文版最新更新]" .B 2001/09/03 .SH "《中國 Linux 論壇 man 手冊頁翻譯計劃》:" .BI http://cmpp.linuxforum.net .SH "跋" .br 本頁面中文版由中文 man 手冊頁計劃提供。 .br 中文 man 手冊頁計劃:\fBhttps://github.com/man-pages-zh/manpages-zh\fR