{"id":6281,"date":"2022-12-20T18:58:05","date_gmt":"2022-12-20T21:58:05","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/file-mann\/"},"modified":"2022-12-20T18:58:05","modified_gmt":"2022-12-20T21:58:05","slug":"file-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/file-mann\/","title":{"rendered":"file (mann)"},"content":{"rendered":"<h1 align=\"center\">file<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#PORTABILITY ISSUES\">PORTABILITY ISSUES<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">file \u2212 Manipulate file names and attributes<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>file<\/b> <i>option name<\/i> ?<i>arg arg &#8230;<\/i>? ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This command provides several operations on a file\u2019s name or attributes. <i>Name<\/i> is the name of a file; if it starts with a tilde, then tilde substitution is done before executing the command (see the manual entry for <b>filename<\/b> for details). <i>Option<\/i> indicates what to do with the file name. Any unique abbreviation for <i>option<\/i> is acceptable. The valid options are: <b><br \/> file atime<\/b> <i>name<\/i> ?<i>time<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a decimal string giving the time at which file <i>name<\/i> was last accessed. If <i>time<\/i> is specified, it is an access time to set for the file. The time is measured in the standard POSIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file does not exist or its access time cannot be queried or set then an error is generated. On Windows, FAT file systems do not support access time.<\/p>\n<p style=\"margin-left:11%;\"><b>file attributes<\/b> <i>name<\/i> <b><br \/> file attributes<\/b> <i>name<\/i> ?<i>option<\/i>? <b><br \/> file attributes<\/b> <i>name<\/i> ?<i>option value option value&#8230;<\/i>?<\/p>\n<p style=\"margin-left:22%;\">This subcommand returns or sets platform specific values associated with a file. The first form returns a list of the platform specific flags and their values. The second form returns the value for the specific option. The third form sets one or more of the values. The values are as follows:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">On Unix, <b>\u2212group<\/b> gets or sets the group name for the file. A group id can be given to the command, but it returns a group name. <b>\u2212owner<\/b> gets or sets the user name of the owner of the file. The command returns the owner name, but the numerical id can be passed when setting the owner. <b>\u2212permissions<\/b> sets or retrieves the octal code that chmod(1) uses. This command does also has limited support for setting using the symbolic attributes for chmod(1), of the form [ugo]?[[+\u2212=][rwxst],[&#8230;]], where multiple symbolic attributes can be separated by commas (example: <b>u+s,go\u2212rw<\/b> add sticky bit for user, remove read and write permissions for group and other). A simplified <b>ls<\/b> style string, of the form rwxrwxrwx (must be 9 characters), is also supported (example: <b>rwxr\u2212xr\u2212t<\/b> is equivalent to 01755). On versions of Unix supporting file flags, <b>\u2212readonly<\/b> gives the value or sets or clears the readonly attribute of the file, i.e. the user immutable flag <b>uchg<\/b> to chflags(1).<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">On Windows, <b>\u2212archive<\/b> gives the value or sets or clears the archive attribute of the file. <b>\u2212hidden<\/b> gives the value or sets or clears the hidden attribute of the file. <b>\u2212longname<\/b> will expand each path element to its long version. This attribute cannot be set. <b>\u2212readonly<\/b> gives the value or sets or clears the readonly attribute of the file. <b>\u2212shortname<\/b> gives a string where every path element is replaced with its short (8.3) version of the name. This attribute cannot be set. <b>\u2212system<\/b> gives or sets or clears the value of the system attribute of the file.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">On Mac OS X and Darwin, <b>\u2212creator<\/b> gives or sets the Finder creator type of the file. <b>\u2212hidden<\/b> gives or sets or clears the hidden attribute of the file. <b>\u2212readonly<\/b> gives or sets or clears the readonly attribute of the file. <b>\u2212rsrclength<\/b> gives the length of the resource fork of the file, this attribute can only be set to the value 0, which results in the resource fork being stripped off the file.<\/p>\n<p style=\"margin-left:11%;\"><b>file channels<\/b> ?<i>pattern<\/i>?<\/p>\n<p style=\"margin-left:22%;\">If <i>pattern<\/i> is not specified, returns a list of names of all registered open channels in this interpreter. If <i>pattern<\/i> is specified, only those names matching <i>pattern<\/i> are returned. Matching is determined using the same rules as for <b>string match<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>file copy<\/b> ?<b>\u2212force<\/b>? ?<b>\u2212\u2212<\/b>? <i>source target<\/i> <b><br \/> file copy<\/b> ?<b>\u2212force<\/b>? ?<b>\u2212\u2212<\/b>? <i>source<\/i> ?<i>source<\/i> &#8230;? <i>targetDir<\/i><\/p>\n<p style=\"margin-left:22%;\">The first form makes a copy of the file or directory <i>source<\/i> under the pathname <i>target<\/i>. If <i>target<\/i> is an existing directory, then the second form is used. The second form makes a copy inside <i>targetDir<\/i> of each <i>source<\/i> file listed. If a directory is specified as a <i>source<\/i>, then the contents of the directory will be recursively copied into <i>targetDir<\/i>. Existing files will not be overwritten unless the <b>\u2212force<\/b> option is specified (when Tcl will also attempt to adjust permissions on the destination file or directory if that is necessary to allow the copy to proceed). When copying within a single filesystem, <i>file copy<\/i> will copy soft links (i.e. the links themselves are copied, not the things they point to). Trying to overwrite a non-empty directory, overwrite a directory with a file, or overwrite a file with a directory will all result in errors even if <b>\u2212force<\/b> was specified. Arguments are processed in the order specified, halting at the first error, if any. A <b>\u2212\u2212<\/b> marks the end of switches; the argument following the <b>\u2212\u2212<\/b> will be treated as a <i>source<\/i> even if it starts with a <b>\u2212<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>file delete<\/b> ?<b>\u2212force<\/b>? ?<b>\u2212\u2212<\/b>? ?<i>pathname<\/i> &#8230; ?<\/p>\n<p style=\"margin-left:22%;\">Removes the file or directory specified by each <i>pathname<\/i> argument. Non-empty directories will be removed only if the <b>\u2212force<\/b> 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 <b>\u2212force<\/b> flags is not specified. If the <b>\u2212force<\/b> option is specified on a directory, Tcl will attempt both to change permissions and move the current directory \u201cpwd\u201d out of the given path if that is necessary to allow the deletion to proceed. Arguments are processed in the order specified, halting at the first error, if any. A <b>\u2212\u2212<\/b> marks the end of switches; the argument following the <b>\u2212\u2212<\/b> will be treated as a <i>pathname<\/i> even if it starts with a <b>\u2212<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>file dirname<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a name comprised of all of the path components in <i>name<\/i> excluding the last element. If <i>name<\/i> is a relative file name and only contains one path element, then returns \u201c<b>.<\/b>\u201d. If <i>name<\/i> refers to a root directory, then the root directory is returned. For example,<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>file dirname<\/b> c:\/<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">returns <b>c:\/<\/b>.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">Note that tilde substitution will only be performed if it is necessary to complete the command. For example,<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>file dirname<\/b> ~\/src\/foo.c<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">returns <b>~\/src<\/b>, whereas<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>file dirname<\/b> ~<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">returns <b>\/home<\/b> (or something similar).<\/p>\n<p style=\"margin-left:11%;\"><b>file executable<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns <b>1<\/b> if file <i>name<\/i> is executable by the current user, <b>0<\/b> otherwise. On Windows, which does not have an executable attribute, the command treats all directories and any files with extensions <b>exe<\/b>, <b>com<\/b>, <b>cmd<\/b> or <b>bat<\/b> as executable.<\/p>\n<p style=\"margin-left:11%;\"><b>file exists<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns <b>1<\/b> if file <i>name<\/i> exists and the current user has search privileges for the directories leading to it, <b>0<\/b> otherwise.<\/p>\n<p style=\"margin-left:11%;\"><b>file extension<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns all of the characters in <i>name<\/i> after and including the last dot in the last element of <i>name<\/i>. If there is no dot in the last element of <i>name<\/i> then returns the empty string.<\/p>\n<p style=\"margin-left:11%;\"><b>file isdirectory<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns <b>1<\/b> if file <i>name<\/i> is a directory, <b>0<\/b> otherwise.<\/p>\n<p style=\"margin-left:11%;\"><b>file isfile<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns <b>1<\/b> if file <i>name<\/i> is a regular file, <b>0<\/b> otherwise.<\/p>\n<p style=\"margin-left:11%;\"><b>file join<\/b> <i>name<\/i> ?<i>name &#8230;<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Takes one or more file names and combines them, using the correct path separator for the current platform. If a particular <i>name<\/i> is relative, then it will be joined to the previous file name argument. Otherwise, any earlier arguments will be discarded, and joining will proceed from the current argument. For example,<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>file join<\/b> a b \/foo bar<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">returns <b>\/foo\/bar<\/b>.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">Note that any of the names can contain separators, and that the result is always canonical for the current platform: <b>\/<\/b> for Unix and Windows.<\/p>\n<p style=\"margin-left:11%;\"><b>file link<\/b> ?<i>\u2212linktype<\/i>? <i>linkName<\/i> ?<i>target<\/i>?<\/p>\n<p style=\"margin-left:22%;\">If only one argument is given, that argument is assumed to be <i>linkName<\/i>, and this command returns the value of the link given by <i>linkName<\/i> (i.e. the name of the file it points to). If <i>linkName<\/i> is not a link or its value cannot be read (as, for example, seems to be the case with hard links, which look just like ordinary files), then an error is returned.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">If 2 arguments are given, then these are assumed to be <i>linkName<\/i> and <i>target<\/i>. If <i>linkName<\/i> already exists, or if <i>target<\/i> does not exist, an error will be returned. Otherwise, Tcl creates a new link called <i>linkName<\/i> which points to the existing filesystem object at <i>target<\/i> (which is also the returned value), where the type of the link is platform-specific (on Unix a symbolic link will be the default). This is useful for the case where the user wishes to create a link in a cross-platform way, and does not care what type of link is created.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">If the user wishes to make a link of a specific type only, (and signal an error if for some reason that is not possible), then the optional <i>\u2212linktype<\/i> argument should be given. Accepted values for <i>\u2212linktype<\/i> are \u201c<b>\u2212symbolic<\/b>\u201d and \u201c<b>\u2212hard<\/b>\u201d.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">On Unix, symbolic links can be made to relative paths, and those paths must be relative to the actual <i>linkName<\/i>\u2019s location (not to the cwd), but on all other platforms where relative links are not supported, target paths will always be converted to absolute, normalized form before the link is created (and therefore relative paths are interpreted as relative to the cwd). Furthermore, \u201c~user\u201d paths are always expanded to absolute form. When creating links on filesystems that either do not support any links, or do not support the specific type requested, an error message will be returned. Most Unix platforms support both symbolic and hard links (the latter for files only). Windows supports symbolic directory links and hard file links on NTFS drives.<\/p>\n<p style=\"margin-left:11%;\"><b>file lstat<\/b> <i>name varName<\/i><\/p>\n<p style=\"margin-left:22%;\">Same as <b>stat<\/b> option (see below) except uses the <i>lstat<\/i> kernel call instead of <i>stat<\/i>. This means that if <i>name<\/i> refers to a symbolic link the information returned in <i>varName<\/i> is for the link rather than the file it refers to. On systems that do not support symbolic links this option behaves exactly the same as the <b>stat<\/b> option.<\/p>\n<p style=\"margin-left:11%;\"><b>file mkdir<\/b> ?<i>dir<\/i> &#8230;?<\/p>\n<p style=\"margin-left:22%;\">Creates each directory specified. For each pathname <i>dir<\/i> specified, this command will create all non-existing parent directories as well as <i>dir<\/i> itself. If an existing directory is specified, then no action is taken and no error is returned. Trying to overwrite an existing file with a directory will result in an error. Arguments are processed in the order specified, halting at the first error, if any.<\/p>\n<p style=\"margin-left:11%;\"><b>file mtime<\/b> <i>name<\/i> ?<i>time<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a decimal string giving the time at which file <i>name<\/i> was last modified. If <i>time<\/i> is specified, it is a modification time to set for the file (equivalent to Unix <b>touch<\/b>). The time is measured in the standard POSIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file does not exist or its modified time cannot be queried or set then an error is generated.<\/p>\n<p style=\"margin-left:11%;\"><b>file nativename<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns the platform-specific name of the file. This is useful if the filename is needed to pass to a platform-specific call, such as to a subprocess via <b>exec<\/b> under Windows (see <b>EXAMPLES<\/b> below).<\/p>\n<p style=\"margin-left:11%;\"><b>file normalize<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a unique normalized path representation for the file-system object (file, directory, link, etc), whose string value can be used as a unique identifier for it. A normalized path is an absolute path which has all \u201c..\/\u201d and \u201c.\/\u201d removed. Also it is one which is in the \u201cstandard\u201d format for the native platform. On Unix, this means the segments leading up to the path must be free of symbolic links\/aliases (but the very last path component may be a symbolic link), and on Windows it also means we want the long form with that form\u2019s case-dependence (which gives us a unique, case-dependent path). The one exception concerning the last link in the path is necessary, because Tcl or the user may wish to operate on the actual symbolic link itself (for example <b>file delete<\/b>, <b>file rename<\/b>, <b>file copy<\/b> are defined to operate on symbolic links, not on the things that they point to).<\/p>\n<p style=\"margin-left:11%;\"><b>file owned<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns <b>1<\/b> if file <i>name<\/i> is owned by the current user, <b>0<\/b> otherwise.<\/p>\n<p style=\"margin-left:11%;\"><b>file pathtype<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns one of <b>absolute<\/b>, <b>relative<\/b>, <b>volumerelative<\/b>. If <i>name<\/i> refers to a specific file on a specific volume, the path type will be <b>absolute<\/b>. If <i>name<\/i> refers to a file relative to the current working directory, then the path type will be <b>relative<\/b>. If <i>name<\/i> refers to a file relative to the current working directory on a specified volume, or to a specific file on the current working volume, then the path type is <b>volumerelative<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>file readable<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns <b>1<\/b> if file <i>name<\/i> is readable by the current user, <b>0<\/b> otherwise.<\/p>\n<p style=\"margin-left:11%;\"><b>file readlink<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns the value of the symbolic link given by <i>name<\/i> (i.e. the name of the file it points to). If <i>name<\/i> is not a symbolic link or its value cannot be read, then an error is returned. On systems that do not support symbolic links this option is undefined.<\/p>\n<p style=\"margin-left:11%;\"><b>file rename<\/b> ?<b>\u2212force<\/b>? ?<b>\u2212\u2212<\/b>? <i>source target<\/i> <b><br \/> file rename<\/b> ?<b>\u2212force<\/b>? ?<b>\u2212\u2212<\/b>? <i>source<\/i> ?<i>source<\/i> &#8230;? <i>targetDir<\/i><\/p>\n<p style=\"margin-left:22%;\">The first form takes the file or directory specified by pathname <i>source<\/i> and renames it to <i>target<\/i>, moving the file if the pathname <i>target<\/i> specifies a name in a different directory. If <i>target<\/i> is an existing directory, then the second form is used. The second form moves each <i>source<\/i> file or directory into the directory <i>targetDir<\/i>. Existing files will not be overwritten unless the <b>\u2212force<\/b> option is specified. When operating inside a single filesystem, Tcl will rename symbolic links rather than the things that they point to. Trying to overwrite a non-empty directory, overwrite a directory with a file, or a file with a directory will all result in errors. Arguments are processed in the order specified, halting at the first error, if any. A <b>\u2212\u2212<\/b> marks the end of switches; the argument following the <b>\u2212\u2212<\/b> will be treated as a <i>source<\/i> even if it starts with a <b>\u2212<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>file rootname<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns all of the characters in <i>name<\/i> up to but not including the last \u201c.\u201d character in the last component of name. If the last component of <i>name<\/i> does not contain a dot, then returns <i>name<\/i>.<\/p>\n<p style=\"margin-left:11%;\"><b>file separator<\/b> ?<i>name<\/i>?<\/p>\n<p style=\"margin-left:22%;\">If no argument is given, returns the character which is used to separate path segments for native files on this platform. If a path is given, the filesystem responsible for that path is asked to return its separator character. If no file system accepts <i>name<\/i>, an error is generated.<\/p>\n<p style=\"margin-left:11%;\"><b>file size<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a decimal string giving the size of file <i>name<\/i> in bytes. If the file does not exist or its size cannot be queried then an error is generated.<\/p>\n<p style=\"margin-left:11%;\"><b>file split<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a list whose elements are the path components in <i>name<\/i>. The first element of the list will have the same path type as <i>name<\/i>. All other elements will be relative. Path separators will be discarded unless they are needed to ensure that an element is unambiguously relative. For example, under Unix<\/p>\n<p style=\"margin-left:32%; margin-top: 1em\"><b>file split<\/b> \/foo\/~bar\/baz<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">returns \u201c<b>\/ foo .\/~bar baz<\/b>\u201d to ensure that later commands that use the third component do not attempt to perform tilde substitution.<\/p>\n<p style=\"margin-left:11%;\"><b>file stat<\/b> <i>name varName<\/i><\/p>\n<p style=\"margin-left:22%;\">Invokes the <b>stat<\/b> kernel call on <i>name<\/i>, and uses the variable given by <i>varName<\/i> to hold information returned from the kernel call. <i>VarName<\/i> is treated as an array variable, and the following elements of that variable are set: <b>atime<\/b>, <b>ctime<\/b>, <b>dev<\/b>, <b>gid<\/b>, <b>ino<\/b>, <b>mode<\/b>, <b>mtime<\/b>, <b>nlink<\/b>, <b>size<\/b>, <b>type<\/b>, <b>uid<\/b>. Each element except <b>type<\/b> is a decimal string with the value of the corresponding field from the <b>stat<\/b> return structure; see the manual entry for <b>stat<\/b> for details on the meanings of the values. The <b>type<\/b> element gives the type of the file in the same form returned by the command <b>file type<\/b>. This command returns an empty string.<\/p>\n<p style=\"margin-left:11%;\"><b>file system<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a list of one or two elements, the first of which is the name of the filesystem to use for the file, and the second, if given, an arbitrary string representing the filesystem-specific nature or type of the location within that filesystem. If a filesystem only supports one type of file, the second element may not be supplied. For example the native files have a first element \u201cnative\u201d, and a second element which when given is a platform-specific type name for the file\u2019s system (e.g. \u201cNTFS\u201d, \u201cFAT\u201d, on Windows). A generic virtual file system might return the list \u201cvfs ftp\u201d to represent a file on a remote ftp site mounted as a virtual filesystem through an extension called \u201cvfs\u201d. If the file does not belong to any filesystem, an error is generated.<\/p>\n<p style=\"margin-left:11%;\"><b>file tail<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns all of the characters in the last filesystem component of <i>name<\/i>. Any trailing directory separator in <i>name<\/i> is ignored. If <i>name<\/i> contains no separators then returns <i>name<\/i>. So, <b>file tail a\/b<\/b>, <b>file tail a\/b\/<\/b> and <b>file tail b<\/b> all return <b>b<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>file tempfile<\/b> ?<i>nameVar<\/i>? ?<i>template<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Creates a temporary file and returns a read-write channel opened <big>\u2502<\/big> on that file. If the <i>nameVar<\/i> is given, it specifies a variable <big>\u2502<\/big> that the name of the temporary file will be written into; if <big>\u2502<\/big> absent, Tcl will attempt to arrange for the temporary file to be <big>\u2502<\/big> deleted once it is no longer required. If the <i>template<\/i> is <big>\u2502<\/big> present, it specifies parts of the template of the filename to <big>\u2502<\/big> use when creating it (such as the directory, base-name or <big>\u2502<\/big> extension) though some platforms may ignore some or all of these <big>\u2502<\/big> parts and use a built-in default instead. <big>\u2502<\/big><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">Note that temporary files are <i>only<\/i> ever created on the native <big>\u2502<\/big> filesystem. As such, they can be relied upon to be used with <big>\u2502<\/big> operating-system native APIs and external programs that require <big>\u2502<\/big> a filename. <big>\u2502<\/big><\/p>\n<p style=\"margin-left:11%;\"><b>file type<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a string giving the type of file <i>name<\/i>, which will be one of <b>file<\/b>, <b>directory<\/b>, <b>characterSpecial<\/b>, <b>blockSpecial<\/b>, <b>fifo<\/b>, <b>link<\/b>, or <b>socket<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>file volumes<\/b><\/p>\n<p style=\"margin-left:22%;\">Returns the absolute paths to the volumes mounted on the system, as a proper Tcl list. Without any virtual filesystems mounted as root volumes, on UNIX, the command will always return \u201c\/\u201d, since all filesystems are locally mounted. On Windows, it will return a list of the available local drives (e.g. \u201ca:\/ c:\/\u201d). If any virtual filesystem has mounted additional volumes, they will be in the returned list.<\/p>\n<p style=\"margin-left:11%;\"><b>file writable<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns <b>1<\/b> if file <i>name<\/i> is writable by the current user, <b>0<\/b> otherwise.<\/p>\n<h2>PORTABILITY ISSUES <a name=\"PORTABILITY ISSUES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Unix<\/b><\/p>\n<p style=\"margin-left:22%;\">These commands always operate using the real user and group identifiers, not the effective ones.<\/p>\n<p style=\"margin-left:11%;\"><b>Windows<\/b><\/p>\n<p style=\"margin-left:22%;\">The <b>file owned<\/b> subcommand uses the user identifier (SID) of the process token, not the thread token which may be impersonating some other user.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This procedure shows how to search for C files in a given directory that have a correspondingly-named object file in the current directory:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">proc findMatchingCFiles {dir} { <br \/> set files {} <br \/> switch $::tcl_platform(platform) { <br \/> windows { <br \/> set ext .obj <br \/> } <br \/> unix { <br \/> set ext .o <br \/> } <br \/> } <br \/> foreach file [glob \u2212nocomplain \u2212directory $dir *.c] { <br \/> set objectFile [<b>file tail<\/b> [<b>file rootname<\/b> $file]]$ext <br \/> if {[<b>file exists<\/b> $objectFile]} { <br \/> lappend files $file <br \/> } <br \/> } <br \/> return $files <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Rename a file and leave a symbolic link pointing from the old location to the new place:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">set oldName foobar.txt <br \/> set newName foo\/bar.txt <br \/> # Make sure that where we\u2019re going to move to exists&#8230; <br \/> if {![<b>file isdirectory<\/b> [<b>file dirname<\/b> $newName]]} { <b><br \/> file mkdir<\/b> [<b>file dirname<\/b> $newName] <br \/> } <b><br \/> file rename<\/b> $oldName $newName <b><br \/> file link<\/b> \u2212symbolic $oldName $newName<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">On Windows, a file can be \u201cstarted\u201d easily enough (equivalent to double-clicking on it in the Explorer interface) but the name passed to the operating system must be in native format:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">exec {*}[auto_execok start] {} [<b>file nativename<\/b> ~\/example.txt]<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">filename(n), open(n), close(n), eof(n), gets(n), tell(n), seek(n), fblocked(n), flush(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">attributes, copy files, delete files, directory, file, move files, name, rename files, stat, user<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  file \u2212 Manipulate file names and attributes <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2617,2635],"class_list":["post-6281","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-file","tag-mann"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6281"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6281\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}