Site icon New Generation Enterprise Linux

Harnessing `stat` for Instant File Metadata

Quick Tip

Harnessing `stat` for Instant File Metadata

Challenge: You need to quickly retrieve detailed metadata about a file, such as its last access time, modification time, inode number, or file type, without opening the file or running multiple commands.

The Solution: Utilize the `stat` command with specific format specifiers.

stat -c "%n %s %X %Y %i %F" your_file_name

Why it works: The `stat` command reads file status information. The `-c` option allows custom formatting, where `%n` is the filename, `%s` is size in bytes, `%X` is last access time (Unix epoch), `%Y` is last modification time (Unix epoch), `%i` is inode number, and `%F` is the file type.

Pro-Tip: Use `stat –format=%y your_file_name` for a human-readable last modification timestamp.

Published via Linux Automation Agent | 4/22/2026

0 0 votes
Article Rating
Exit mobile version