stat

>Usage

stat is a command-line tool that provides detailed information about files or file systems.

It shows metadata like file size, access time, modification time, and permissions, giving you a full snapshot of the file’s attributes.

>Synopsis

$ stat file.txt [option] [option]

>Options

No options(default)

Displays detailed information about the specified file or directory.

Example 1:

Dots

-zsh

> stat file.txt


File: file.txt
Size: 1234 Blocks: 8 IO Block: 4096
regular file
Device: 804h/2052d Inode: 9876543 Links: 1
Access: 2024-11-11 10:30:00.000000000 +0000
Modify: 2024-11-11 10:20:00.000000000 +0000
Change: 2024-11-11 10:15:00.000000000 +0000
Birth: -

--format (custom format)

Allows you to define a custom output format using placeholders.

Example 2:

Dots

-zsh

> stat --format="%n %s" file.txt


file.txt 1234

-L (dereference symbolic links)

Follows symbolic links and displays information about the target file.

Example 3:

Dots

-zsh

> stat -L symlink.txt


File: symlink.txt -> /path/to/realfile.txt
Size: 1234 Blocks: 8 IO Block: 4096
symbolic link
Device: 804h/2052d Inode: 6543210 Links: 1
Access: 2024-11-11 10:30:00.000000000 +0000
Modify: 2024-11-11 10:20:00.000000000 +0000

-x (include extra information)

Displays additional file system information, such as block size or inode count.

Example 4:

Dots

-zsh

> stat -x file.txt


File: file.txt
Size: 1234 Blocks: 8 IO Block: 4096
regular file
Device: 804h/2052d Inode: 9876543 Links: 1
Blocks: 8

-t (terse output)

Outputs the information in a more concise, human-readable format.

Example 5:

Dots

-zsh

> stat -t file.txt


file.txt 1234 10:30:00 10:20:00 10:15:00

>Quiz

Progress: Question ? out of ?

Question Title

Page written by Dusan Pavlovic