file stat

file stat name varName

Invokes the stat kernel call on name, and uses the variable given by varName to hold information returned from the kernel call. VarName is treated as an array variable, and the following elements of that variable are set: atime, ctime, dev, gid, ino, mode, mtime, nlink, size, type, uid. On some platforms, including POSIX-like systems, blksize and blocks, are also provided.

Each element except type is a decimal string with the value of the corresponding field from the stat return structure; see the manual entry for stat for details on the meanings of the values. The type element gives the type of the file in the same form returned by the command file type. This command returns an empty string.

AMG: Maybe we can extend [file stat] to not require the varName argument. If omitted, it would instead return a dict containing everything that would have gone into the varName array.

A combination of glob and file stat can be used, for instance, to implement ls -l in Tcl.

See also