Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check the modification date of a file in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to check the modification date of the file in Linux. The article is very detailed and has a certain reference value. Interested friends must finish reading it!

Use the stat command

The stat command can display the details of the file attributes, such as the last time the file was accessed and modified, the file size and other information. It is easy to use. You only need to add the file name after the command:

[root@localhost ~] # stat hello_script.sh File: 'hello_script.sh' Size: 31 Blocks: 8 IO Block: 4096 regular file Device: fd00h/64768d Inode: 67169379 Links: 1 Access: (0755/-rwxr-xr-x) Uid: (0 / root) Gid: (0 / root) Context: unconfined_u:object_r:admin_home_t:s0 Access: 2020-10 -15 19 13 Modify 24.628009932 + 0800 Birth: 2020-10-15 19V 07V 07V 18.266426499 + 0800 Birth: 2020-10-15 19V 11v 48.227856412--

From the output above, we can see the access date of the file, the modification date of the file, the modification date of the file permissions, and other parameters.

If you only want to see the modification date of the file, without considering all other information, run the following command:

[root@localhost] # stat-c% y hello_script.sh 2020-10-15 19 hello_script.sh 07Vol 18.266426499 + 0800

The-c option is used to specify a custom format instead of the default output, while the'% y' flag shows when it was last modified. For folders, the syntax remains the same. Simply replace the file name with the folder name.

Use the date command

The use of the date command is to display the current date. However, when used with the-r option, you can display the last modification date of the file, as follows:

[root@localhost] # date-r hello_script.sh Thu Oct 15 19:07:18 CST 2020

Use the ls-l command

The ls-l command is typically used to use a long list to display other information about a file, such as file permissions and owners, size, and creation date. You can add the-t option so that it can be arranged according to the modification time of the file:

[root@localhost] # ls-lt or [root@localhost ~] # ll-t total 288drwxr-xr-x. 2 root root 177 Oct 16 14:36 b drwxr-xr-x. 2 root root 177Oct 16 14:36 a-rwxr-xr-x. 1 root root 119 Oct 15 19:20 backup_script.sh-rwxr-xr-x. 1 root root 31 Oct 15 19:07 hello_script.sh-rw-r--r--. 1 root root 227 Oct 13 16:39 content.txt-rw-r--r--. 1 root root 277159 Oct 12 14:37 a.txt drwxr-xr-x. 2 root root 195 Aug 6 14:12 Files-rw-. 1 root root 1284 Dec 29 2019 anaconda-ks.cfg

Use the httpie tool

Another way to check the modification date of a file is to use httpie, which is the HTTP command line client tool. This tool is typically used to interact with HTTP servers and API, and to check the modification time of files that reside on web servers.

You first need to make sure that python's pip package management tools are installed, and then install the httpie tools:

In Centos7/RHEL7, run the following command to install httpie:

[root@localhost] # yum-y install python-pip [root@localhost ~] # pip install-- upgrade pip [root@localhost ~] # pip install httpie

Run the following command in Ubuntu / Deepin / Debian to install httpie:

$sudo apt install httpie

After the installation is complete, how can I check the modification time of the files on the web server? The syntax is as follows:

Http-h [url] | grep 'Last-Modified'

For example, from the www.linuxprobe.com website, view the modification time of a picture in .png format:

[root@localhost ~] # http-h https://www.linuxprobe.com/wp-content/uploads/2020/06/6-1.png | grep-I 'Last-Modified' Last-Modified: Fri, 05 Jun 2020 14:26:11 GMT

The above is all the contents of the article "how to check the modification date of a file in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report