The file command provides several ways to check the status of files in the file system. For example, you can find out if a file exists, what type of file it is, and other file attributes. There are facilities for manipulating files in a platform-independent manner. Table 9-2 provides a summary of the various forms of the file command. They are described in more detail later. Note that the split, join, and pathtype operations were added in Tcl 7.5. The copy, delete, mkdir, and rename operations were added in Tcl 7.6. The attributes operation was added in Tcl 8.0
file atime name | Returns access time as a decimal string. |
file attributes name ?option? ?value? ... | Queries or sets file attributes. (Tcl 8.0) |
file copy ?-force? source destination | Copies file source to file destination. The source and destination can be directories. (Tcl 7.6) |
file delete ?-force? name | Deletes the named file. (Tcl 7.6) |
file dirname name | Returns parent directory of file name. |
file executable name | Returns 1 if name has execute permission, else 0. |
file exists name | Returns 1 if name exists, else 0. |
file extension name | Returns the part of name from the last dot (i.e., .) to the end. The dot is included in the return value. |
file isdirectory name | Returns 1 if name is a directory, else 0. |
file isfile name | Returns 1 if name is not a directory, symbolic link, or device, else 0. |
file join path path... | Joins pathname components into a new pathname. (Tcl 7.5) |
file lstat name var | Places attributes of the link name into var. |
file mkdir name | Creates directory name. (Tcl 7.6) |
file mtime name | Returns modify time of name as a decimal string. |
file nativename name | Returns the platform-native version of name. (Tk 8.0). |
file owned name | Returns 1 if current user owns the file name, else 0. |
file pathtype name | relative, absolute, or driverelative. (Tcl 7.5) |
file readable name | Returns 1 if name has read permission, else 0. |
file readlink name | Returns the contents of the symbolic link name. |
file rename ?-force? old new | Changes the name of old to new. (Tcl 7.6) |
file rootname name | Returns all but the extension of name (i.e., up to but not including the last . in name). |
file size name | Returns the number of bytes in name. |
file split name | Splits name into its pathname components. (Tcl 7.5) |
file stat name var | Places attributes of name into array var. The elements defined for var are listed in Table 9-3. |
file tail name | Returns the last pathname component of name. |
file type name | Returns type identifier, which is one of: file, directory, characterSpecial, blockSpecial, fifo, link, or socket. |
file writable name | Returns 1 if name has write permission, else 0. |
18.117.188.64