stat
Files and directories
Usage
stat [file]Shows the inode record — size, permission bits, owner and the three timestamps; the format flag is -c on GNU but -f on BSD, where the GNU -f means something else entirely.
Common flags
| Flag | Meaning |
|---|---|
| -c | GNU: choose the output format, as in -c %s |
| -f | GNU: describe the filesystem. On BSD and macOS -f is the format string |
| -L | Follow symlinks and report the target |
| -x | BSD and macOS: verbose, labelled output |
| --printf | GNU: like -c but adds no newline |
Examples
stat -c '%s %n' notes.mdSize and name (GNU).
stat -f '%z %N' notes.mdThe same two values on macOS or BSD.
stat notes.mdFull record: size, mode, owner and the timestamps.
Moving, deleting and finding. Some of these do not ask twice, which is why -i becomes a habit.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does stat do?
Shows the inode record — size, permission bits, owner and the three timestamps; the format flag is -c on GNU but -f on BSD, where the GNU -f means something else entirely.
Q. How do I type it?
stat [file] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
5 are listed here; the full set is in man stat. This command sits under Files and directories.
Related commands
man page: man stat