Languages
[Edit]
EN

Bash - get file modification, access and change times

10 points
Created by:
Khloe-Kaiser
398

In this short article, we would like to show how to get a modification, access, and change times for any file under Bash / Linux.

Quick solution (run the following command):

stat path/to/file.txt

Example output:

  File: path/to/file.txt
  Size: 4               Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d      Inode: 37752       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-09-14 13:10:32.089482633 +0200
Modify: 2021-09-14 13:10:46.558002340 +0200
Change: 2021-09-14 13:11:30.923595933 +0200
 Birth: -

Where:

  • Access: 2021-09-14 13:10:32.089482633 +0200
    indicates the time when the file was accessed last time,
  • Modify: 2021-09-14 13:10:46.558002340 +0200
    indicated the time when file content was changed last time (e.g. some data was written),
  • Change: 2021-09-14 13:11:30.923595933 +0200
    indicates the time when file metadata was changed last time (e.g. file name was changed).
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join