📄 file.n
字号:
'\"'\" 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.23 2003/02/28 12:11:49 vincentdarley Exp $'\" .so man.macros.TH file n 8.3 Tcl "Tcl Built-In Commands".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMEfile \- Manipulate file names and attributes.SH SYNOPSIS\fBfile \fIoption\fR \fIname\fR ?\fIarg arg ...\fR?.BE.SH DESCRIPTION.PPThis command provides several operations on a file's name or attributes.\fIName\fR is the name of a file; if it starts with a tilde, then tildesubstitution is done before executing the command (see the manual entry for\fBfilename\fR for details). \fIOption\fR indicates what to do with thefile name. Any unique abbreviation for \fIoption\fR is acceptable. Thevalid options are:.TP\fBfile atime \fIname\fR ?\fBtime\fR?.Returns a decimal string giving the time at which file \fIname\fR was lastaccessed. If \fItime\fR is specified, it is an access time to setfor the file. The time is measured in the standard POSIX fashion asseconds from a fixed starting time (often January 1, 1970). If the filedoesn't exist or its access time cannot be queried or set then an error isgenerated. On Windows, FAT file systems do not support access time..TP\fBfile attributes \fIname\fR.TP\fBfile attributes \fIname\fR ?\fBoption\fR?.TP\fBfile attributes \fIname\fR ?\fBoption value option value...\fR?.RSThis subcommand returns or sets platform specific values associatedwith a file. The first form returns a list of the platform specificflags and their values. The second form returns the value for thespecific option. The third form sets one or more of the values. Thevalues are as follows:.PPOn Unix, \fB-group\fR gets or sets the group name for the file. A group idcan be given to the command, but it returns a group name. \fB-owner\fR getsor sets the user name of the owner of the file. The command returns theowner name, but the numerical id can be passed when setting theowner. \fB-permissions\fR sets or retrieves the octal code that chmod(1)uses. This command does also has limited support for setting using thesymbolic attributes for chmod(1), of the form [ugo]?[[+\-=][rwxst],[...]],where multiple symbolic attributes can be separated by commas (example:\fBu+s,go\-rw\fR add sticky bit for user, remove read and writepermissions for group and other). A simplified \fBls\fR style string,of the form rwxrwxrwx (must be 9 characters), is also supported(example: \fBrwxr\-xr\-t\fR is equivalent to 01755)..PPOn Windows, \fB-archive\fR gives the value or sets or clears thearchive attribute of the file. \fB-hidden\fR gives the value or setsor clears the hidden attribute of the file. \fB-longname\fR willexpand each path element to its long version. This attribute cannot beset. \fB-readonly\fR gives the value or sets or clears the readonlyattribute of the file. \fB-shortname\fR gives a string where everypath element is replaced with its short (8.3) version of thename. This attribute cannot be set. \fB-system\fR gives or sets orclears the value of the system attribute of the file..PPOn Macintosh, \fB-creator\fR gives or sets the Finder creator type ofthe file. \fB-hidden\fR gives or sets or clears the hidden attributeof the file. \fB-readonly\fR gives or sets or clears the readonlyattribute of the file. Note that directories can only be locked ifFile Sharing is turned on. \fB-type\fR gives or sets the Finder filetype for the file..RE.VS.TP\fBfile channels ?\fIpattern\fR?.If \fIpattern\fR isn't specified, returns a list of names of allregistered open channels in this interpreter. If \fIpattern\fR isspecified, only those names matching \fIpattern\fR are returned. Matchingis determined using the same rules as for \fBstring match\fR..VE.TP\fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR.TP\fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR.RSThe first form makes a copy of the file or directory \fIsource\fR underthe pathname \fItarget\fR. If \fItarget\fR is an existing directory,then the second form is used. The second form makes a copy inside\fItargetDir\fR of each \fIsource\fR file listed. If a directory isspecified as a \fIsource\fR, then the contents of the directory will berecursively copied into \fItargetDir\fR. Existing files will not beoverwritten unless the \fB\-force\fR option is specified. When copyingwithin a single filesystem, \fIfile copy\fR will copy soft links (i.e.the links themselves are copied, not the things they point to). Tryingto overwrite a non-empty directory, overwrite a directory with a file,or a file with a directory will all result in errors even if\fI\-force\fR was specified. Arguments are processed in the orderspecified, halting at the first error, if any. A \fB\-\|\-\fR marksthe end of switches; the argument following the \fB\-\|\-\fR will betreated as a \fIsource\fR even if it starts with a \fB\-\fR..RE.TP\fBfile delete \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIpathname\fR ?\fIpathname\fR ... ?.Removes the file or directory specified by each \fIpathname\fRargument. Non-empty directories will be removed only if the\fB\-force\fR option is specified. When operating on symbolic links,the links themselves will be deleted, not the objects they point to.Trying to delete a non-existent file is not considered an error.Trying to delete a read-only file will cause the file to be deleted,even if the \fB\-force\fR flags is not specified. If the \fB\-force\fRoption is specified on a directory, Tcl will attempt both to changepermissions and move the current directory 'pwd' out of the given pathif that is necessary to allow the deletion to proceed. Arguments areprocessed in the order specified, halting at the first error, if any.A \fB\-\|\-\fR marks the end of switches; the argument following the\fB\-\|\-\fR will be treated as a \fIpathname\fR even if it starts witha \fB\-\fR..TP\fBfile dirname \fIname\fRReturns a name comprised of all of the path components in \fIname\fRexcluding the last element. If \fIname\fR is a relative file name andonly contains one path element, then returns ``\fB.\fR'' (or ``\fB:\fR''on the Macintosh). If \fIname\fR refers to a root directory, then theroot directory is returned. For example,.RS.CS\fBfile dirname c:/\fR.CEreturns \fBc:/\fR. .PPNote that tilde substitution will only beperformed if it is necessary to complete the command. For example,.CS\fBfile dirname ~/src/foo.c\fR.CEreturns \fB~/src\fR, whereas.CS\fBfile dirname ~\fR.CEreturns \fB/home\fR (or something similar)..RE.TP\fBfile executable \fIname\fR.Returns \fB1\fR if file \fIname\fR is executable by the current user,\fB0\fR otherwise. .TP\fBfile exists \fIname\fR.Returns \fB1\fR if file \fIname\fR exists and the current user hassearch privileges for the directories leading to it, \fB0\fR otherwise..TP\fBfile extension \fIname\fR.Returns all of the characters in \fIname\fR after and including the lastdot in the last element of \fIname\fR. If there is no dot in the lastelement of \fIname\fR then returns the empty string..TP\fBfile isdirectory \fIname\fR.Returns \fB1\fR if file \fIname\fR is a directory, \fB0\fR otherwise..TP\fBfile isfile \fIname\fR.Returns \fB1\fR if file \fIname\fR is a regular file, \fB0\fR otherwise..TP\fBfile join \fIname\fR ?\fIname ...\fR?.Takes one or more file names and combines them, using the correct pathseparator for the current platform. If a particular \fIname\fR isrelative, then it will be joined to the previous file name argument.Otherwise, any earlier arguments will be discarded, and joining willproceed from the current argument. For example,.RS.CS\fBfile join a b /foo bar\fR.CEreturns \fB/foo/bar\fR..PPNote that any of the names can contain separators, and that the resultis always canonical for the current platform: \fB/\fR for Unix andWindows, and \fB:\fR for Macintosh..RE.TP\fBfile link ?\fI-linktype\fR? \fIlinkName\fR ?\fItarget\fR?.If only one argument is given, that argument is assumed to be\fIlinkName\fR, and this command returns the value of the link given by\fIlinkName\fR (i.e. the name of the file it points to). If\fIlinkName\fR isn't a link or its value cannot be read (as, for example,seems to be the case with hard links, which look just like ordinaryfiles), then an error is returned..If 2 arguments are given, then these are assumed to be \fIlinkName\fR and\fItarget\fR. If \fIlinkName\fR already exists, or if \fItarget\fRdoesn't exist, an error will be returned. Otherwise, Tcl creates a newlink called \fIlinkName\fR which points to the existing filesystem objectat \fItarget\fR, where the type of the link is platform-specific (on Unixa symbolic link will be the default). This is useful for the case wherethe user wishes to create a link in a cross-platform way, and doesn'tcare what type of link is created..If the user wishes to make a link of a specific type only, (and signal anerror if for some reason that is not possible), then the optional\fI-linktype\fR argument should be given. Accepted values for
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -