'\" '\" 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: file.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: file.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 file 3tcl 8.3 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME file \- 操縱文件名和屬性 .SH "總覽 SYNOPSIS" \fBfile \fIoption\fR \fIname\fR ?\fIarg arg ...\fR? .BE .SH "描述 DESCRIPTION" .PP 這個命令提供在一個文件名或屬性上的一些操作。\fIName\fR 是一個文件的名字;如果它以波浪線(~)開始,則在執行命令之前進行波浪線替換(詳情參見\fBfilename\fR 命令的手冊條目)。\fIOption\fR 指示對文件名做什麼處理。接受 \fIoption\fR 的任何唯一的縮寫。有效的選項是: .TP \fBfile atime \fIname\fR ?\fBtime\fR? . 返回一個十進制字符串,給出文件 \fIname \fR上次被訪問的時間。如果指定了\fItime\fR,它是這個文件要設置成的訪問時間。這個時間是用標準的 POSIX 方式(fashion)度量的,即從一個固定的開始時間至今的秒數(通常是1970年1月1日)。如果文件不存在或它的訪問時間不可查詢或設置則生成一個錯誤。在 Windows 上,FAT 文件系統不支持訪問時間。 .TP \fBfile attributes \fIname\fR .br \fBfile attributes \fIname\fR ?\fBoption\fR? .br \fBfile attributes \fIname\fR ?\fBoption value option value...\fR? .RS 這個子命令返回或設置與一個文件相關聯的特定於平臺的值。第一種形式返回特定於平臺的標誌(flag)和它們的值的一個列表。第二種形式返回指定選項的值。第三種形式設置一個或多個值。這些值是: .PP 在Unix 上,\fB-group\fR 得到或設置這個文件的組名字。給這個命令一個組ID,而它返回一個組名字。\fB-owner\fR 得到或設置這個文件的屬主的名字。這個命令返回屬主的名字,而在設置屬主的時候要傳遞給它數值的 ID。\fB-permissions\fR 設置或查詢 chmod(1) 所使用的八進制代碼。這個命令還有限的支持使用 chmod(1)的符號屬性來做設置,形式是 [ugo]?[[+\-=][rwxst],[...]],這裏使用逗號來分隔多個符號屬性(例如: \fBu+s,go\-rw\fR 爲用戶添加粘住位(sticky),爲組和其他刪除讀和寫的許可權)。還支持一個簡化的 \fBls\fR式樣的字符串,形式是 rwxrwxrwx (必須是 9 個字符)(例如: \fBrwxr\-xr\-t\fR 等價於01755)。 .PP 在 Windows 上,\fB-archive\fR 給出值或設置或清除這個文件的歸檔屬性。\fB-hidden\fR 給出值或設置或清除這個文件的隱藏屬性。\fB-longname\fR將把每個路徑元素擴展成長版本。不能設置這個屬性。\fB-readonly\fR 給出值或設置或清除這個文件的只讀屬性。\fB-shortname\fR 給出一個字符串,在這裏每個路徑元素被替換成它的短(8.3)版本的文件名。不能設置這個屬性。\fB-system\fR 給出值或設置或清除這個文件的系統屬性。 .PP 在 Macintosh 上,\fB-creator\fR給出或設置這個文件的尋找器(Finder)建立者類型。\fB-hidden\fR給出值或設置或清除這個文件的隱藏屬性。\fB-readonly\fR 給出值或設置或清除這個文件的只讀屬性。注意如果打開了文件共享則目錄只能被鎖定。\fB-type\fR 給出或設置這個文件的尋找器文件類型。 .RE .VS .TP \fBfile channels ?\fIpattern\fR? . 如果沒有指定 \fIpattern\fR,則返回所有在這個解釋器中註冊的打開通道的一個列表。如果指定了 \fIpattern\fR,則只返回匹配\fIpattern\fR 的名字。確定匹配使用與 \fBstring match\fR 相同的規則。 .VE .TP \fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR .br \fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR .RS 第一中形式在路徑名 \fItarget \fR底下做文件或路徑 \fIsource\fR的一個復件。如果 \fItarget\fR 是一個現存的目錄,則使用第二種形式。第二種形式在\fItargetDir \fR中做列出的每個 \fIsource\fR 文件的一個復件。如果指定一個目錄作爲一個 \fIsource\fR,則這個目錄的內容將被遞歸的複製進 \fItargetDir\fR 中。除非指定 \fB\-force\fR 選項否則現存文件將不被覆寫。即使指定了 \fI\-force\fR ,嘗試覆寫一個非空目錄,用一個文件覆寫一個目錄,或者用一個目錄覆寫一個文件將導致錯誤。參數按指定的次序被處理,如果有錯誤的話,在第一個錯誤處停止(halt)。一個 \fB\-\|\-\fR 標記選項的結束;在 \fB\-\|\-\fR 之後的參數即使以 \fB\- \fR開始將仍被作爲一個 \fIsource\fR 來對待。 .RE .TP \fBfile delete \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIpathname\fR ?\fIpathname\fR ... ? . 刪除由每個 \fIpathname\fR 參數所指定的文件或目錄。只有指定 \fB-force\fR選項才刪除非空目錄。嘗試刪除一個不存在文件將導致不作爲一個錯誤來考慮。即使沒有指定 \fB-force\fR 項,嘗試刪除一個只讀文件將導致文件被刪除。參數按指定的次序被處理,如果有錯誤的話,在第一個錯誤處停止(halt)。一個 \fB\-\|\-\fR 標記選項的結束;在 \fB\-\|\-\fR 之後的參數即使以 \fB\- \fR開始將仍被作爲一個 \fIpathname\fR來對待。 .TP \fBfile dirname \fIname\fR 返回一個名字,由在 \fIname\fR 中除了最後一個之外的所有路徑組成部分(component)組成。如果 \fIname\fR 是一個相對的文件名並且只包含一個路徑元素(element),則返回“\fB.\fR” (在 Macintosh 上爲“\fB:\fR”)。如果 \fIname\fR 參照一個根目錄,則返回根目錄。例如, .RS .CS \fBfile dirname c:/\fR .CE 返回 \fBc:/\fR. .PP 注意波浪線替換隻在必要的時候進行用以補全(complete)命令。例如, .CS \fBfile dirname ~/src/foo.c\fR .CE 返回 \fB~/src\fR,而 .CS \fBfile dirname ~\fR .CE 返回 \fB/home\fR (or something similar). .RE .TP \fBfile executable \fIname\fR . 如果文件對當前用戶是可執行的則返回 \fB1\fR,否則返回\fB0\fR。 .TP \fBfile exists \fIname\fR . 如果文件 \fIname\fR 存在並且當前的用戶對找到(lead to)它(所途徑)的目錄有查找的權利(privilege)則返回\fB1\fR,否則返回 \fB0\fR。 .TP \fBfile extension \fIname\fR . 返回在 \fIname \fR最後那個元素的最後一個點號之後幷包括點號的所有在 \fIname\fR中字符。如果在 \fIname\fR 的最後的那個元素中沒有點號則返回空串。 .TP \fBfile isdirectory \fIname\fR . 如果文件 \fIname\fR 是一個目錄則返回 \fB1\fR,否則返回 \fB0\fR。 .TP \fBfile isfile \fIname\fR . 如果文件 \fIname\fR 是一個普通文件則返回 \fB1\fR,否則返回 \fB0\fR。 .TP \fBfile join \fIname\fR ?\fIname ...\fR? . 接受一個或多個文件名並使用對當前平臺正確的路徑分隔符來組合它們。如果特定的 \fIname\fR是相對的,則它會被連接到前面的文件名參數上。否則,丟棄所有以前的參數,從當前的參數開始進行連接。例如 .RS .CS \fBfile join a b /foo bar\fR .CE 返回 \fB/foo/bar\fR. .PP 注意任何名字都可以包含分隔符,並且結果總是依從當前平臺的規矩: 對 Unix 和 Windows 是 \fB/\fR,對 Macintosh 是 \fB:\fR。 .RE .TP \fBfile lstat \fIname varName\fR . 除了使用 \fIlstat\fR 調用而不使用 \fIstat \fR之外,與 \fBstat\fR 選項(見後)相同。這意味着如果 \fIname\fR 參照一個符號連接,在 \fIvarName\fR 中返回的信息是針對這個連接而不是它所引用的那個文件。在不支持符號連接的系統上這個選項的行爲與 \fBstat\fR選項完全一致。 .TP \fBfile mkdir \fIdir\fR ?\fIdir\fR ...? . 建立每個指定的目錄。對於每個指定的路徑名 \fIdir\fR ,象 \fIdir\fR 自身一樣,這個命令將建立所有不存在的父目錄。如果指定了一個現存的目錄,不做動作並不返回錯誤。嘗試用一個目錄覆寫一個現存的文件將導致一個錯誤。參數按指定的次序被處理,如果有錯誤的話,在第一個錯誤處停止(halt)。 .TP \fBfile mtime \fIname\fR ?\fItime\fR? . 返回一個十進制字符串,給出文件 \fIname\fR上次被修改的時間。如果指定了\fItime\fR ,它是這個文件要設置成的修改時間。(等價與 Unix 的 \fBtouch\fR)。這個時間是用標準的 POSIX 方式(fashion)度量的,即從一個固定的開始時間至今的秒數(通常是1970年1月1日)。如果文件不存在或它的修改時間不可查詢或設置則生成一個錯誤。 .TP \fBfile nativename \fIname\fR . 返回文件的特定於平臺的名字。如果這個文件名需要傳遞給特定於系統的調用,比如對在 Windows 下的 exec 或在 Macintosh 上的 AppleScript 將會有用。 .TP \fBfile owned \fIname\fR . 如果文件 \fIname\fR 由當前用戶所有則返回 \fB1\fR,否則返回 \fB0\fR。 .TP \fBfile pathtype \fIname\fR . 返回 \fBabsolute\fR、\fBrelative\fR、\fBvolumerelative \fR中的一個。如果 \fIname\fR 參照一個在指定捲上的指定文件,路徑類型將是 \fBabsolute\fR。如果 \fIname\fR 參照一個相對當前工作目錄的一個文件,則路徑類型將是 \fBrelative\fR。如果 \fIname\fR 參照在指定捲上的相對於當前工作目錄的一個文件,或者在當前工作捲上的指定文件,則路徑類型是 \fBvolumerelative\fR。 .TP \fBfile readable \fIname\fR . 如果文件 \fIname\fR 對當前用戶是可讀的則返回 \fB1\fR,否則返回\fB0\fR。 .TP \fBfile readlink \fIname\fR . 返回由 \fIname\fR 給出的符號連接的值(比如,它指向的文件的名字)。如果 \fIname\fR 不是符號連接或它的值不可讀,則返回一個錯誤。在不支持符號連接的系統上這個選項未定義。 .TP \fBfile rename \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR .TP \fBfile rename \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR .RS 第一種形式接受由路徑名\fIsource\fR 指定的文件或目錄並且把它重命名成 \fItarget\fR,如果路徑名 \fItarget\fR指定了在不同目錄下的一個名字,則移動這個文件。如果 \fItarget\fR 是一個現存的目錄,則使用第二種形式。第二中形式移動每個 \fIsource\fR 文件或目錄到目錄 \fItargetDir \fR中。除非指定了\fB-force\fR選項否則不覆寫現存的文件。嘗試覆寫一個非空目錄,用一個文件覆寫一個目錄,或者用一個目錄覆寫一個文件將導致錯誤。參數按指定的次序被處理,如果有錯誤的話,在第一個錯誤處停止(halt)。一個 \fB\-\|\-\fR 標記選項的結束;在 \fB\-\|\-\fR 之後的參數即使以 \fB\- \fR開始將仍被作爲一個 \fIsource\fR 來對待。 .RE .TP \fBfile rootname \fIname\fR . 返回 \fIname\fR 的最後一個組成部分的最後一個“.”之前但不包括這個“.”的 \fIname\fR中的所有字符。如果 \fIname\fR 的最後的組成部分不包含點號,則返回 \fIname\fR。 .TP \fBfile size \fIname\fR . 返回給出文件 \fIname\fR 的大小的以字節爲單位的一個十進制字符串。如果文件不存在或它的大小不可查詢則生成一個錯誤。 .TP \fBfile split \fIname\fR . 返回一個列表,它的元素是在 \fIname \fR中的路徑的組成部分。列表的第一個元素將與 \fIname \fR有相同的路徑類型。所有其他元素將是相對的。除了需要確保一個元素是相對的而無歧義之外,丟棄路徑分隔符。例如,在 Unix 下 .RS .CS \fBfile split /foo/~bar/baz\fR .CE 返回 \fB/ foo ./~bar baz\fR 來確保以後的命令在第三個組成部分上不進行波浪線替換。 .RE .TP \fBfile stat \fIname varName\fR . 在 \fIname \fR上調用 \fBstat\fR 內核調用,並且使用由 \fIvarName\fR 給出的變量來持有從內核調用返回的信息。\fIVarName\fR 被作爲一個數組變量來對待,並且給這個變量設置下列元素: \fBatime\fR、\fBctime\fR、\fBdev\fR、\fBgid\fR、\fBino\fR、\fBmode\fR、\fBmtime\fR、\fBnlink\fR、\fBsize\fR、\fBtype\fR、\fBuid\fR。除了 \fBtype\fR之外的每個元素都是一個十進制字符串,它們的值來自從 \fBstat\fR 返回的結構中相應的字段。這些值的意義詳見 \fBstat\fR 的手冊條目。\fBtype\fR 元素給出的文件類型與命令 \fBfile type \fR返回的有相同的形式。這個命令返回一個空串。 .TP \fBfile tail \fIname\fR . 返回在最後一個目錄分隔符之後的在 \fIname\fR中的所有字符。如果 \fIname\fR 不包含分隔符則返回\fIname\fR。 .TP \fBfile type \fIname\fR . 返回給出文件 \fIname \fR的類型的一個字符串,它將是\fBfile\fR、\fBdirectory\fR、\fBcharacterSpecial\fR、 \fBblockSpecial\fR、\fBfifo\fR、\fBlink\fR、或 \fBsocket\fR 中的一個。 .TP \fBfile volume\fR . 返回一個適當的 Tcl 列表,給出到掛裝在系統上的卷的絕對路徑。在Macintosh上,將是掛裝驅動器的一個列表,包括本地的和網絡的二者。N.B.(?)如果兩個驅動器有相同的名字,它們都將出現在卷列表上,但當前沒有辦法從Tcl 來訪問除了第一個之外的任何驅動器。在 UNIX 上,命令將總是返回 "/",因爲所有文件系統都是本地掛裝的。在 Windows 上,它將返回可獲得的本地驅動器的一個列表(比如,{a:/ c:/})。 .TP \fBfile writable \fIname\fR . 如果文件 \fIname\fR 對當前用戶是可寫的則返回 \fB1\fR,否則返回 \fB0\fR。 .SH "移植要點 PORTABILITY ISSUES" .TP \fBUnix\fR\0\0\0\0\0\0\0 . 這些命令總是使用真實用戶和組標識而不使用有效用戶和組標識。 .SH "參見 SEE ALSO" filename .SH "關鍵字 KEYWORDS" attributes, copy files, delete files, directory, file, move files, name, rename files, stat .SH "[中文版維護人]" .B 寒蟬退士 .SH "[中文版最新更新]" .B 2001/06/21 .SH "《中國 Linux 論壇 man 手冊頁翻譯計劃》:" .BI http://cmpp.linuxforum.net .SH "跋" .br 本頁面中文版由中文 man 手冊頁計劃提供。 .br 中文 man 手冊頁計劃:\fBhttps://github.com/man-pages-zh/manpages-zh\fR