How to get the last modified time of a file in Linux?


While I was writing a shell script, I needed the last modified time of a particular file before doing something, and here’s what I used:

stat -c ‘%Y’ /root/directory/file.txt

This command will give you the last modified time of a file in seconds (since Epoch).

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 27 other followers

%d bloggers like this: