Name
stat
Synopsis
stat file
Returns a 13-element list giving the statistics for
a file, indicated by either a
filehandle or an expression that gives its name. It’s typically
used as follows:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat $filename;Not all fields are supported on all filesystem types. Here are the meanings of the fields:
Field | Meaning |
|---|---|
| Device number of filesystem |
| Inode number |
| File mode (type and permissions) |
| Number of (hard) links to the file |
| Numeric user ID of file’s owner |
| Numeric group ID of file’s owner |
| The device identifier (special files only) |
| Total size of file, in bytes |
| Last access time since the epoch |
| Last modification time since the epoch |
| Inode change time (not creation time!) since the epoch |
| Preferred blocksize for file system I/O |
| Actual number of blocks allocated |
$dev and $ino, taken together, uniquely identify
a file. The $blksize and
$blocks are likely defined only
on BSD-derived filesystems. The $blocks field (if defined) is reported
in 512-byte blocks. Note that $blocks*512 can differ greatly from
$size for files containing
unallocated blocks, or “holes,” which aren’t counted in $blocks.
If stat is passed the
special filehandle consisting of an underline, no actual stat is done, but the current contents
of the stat structure from the
last stat or stat-based file test (the -x operators) is returned.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access