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 file modification time under Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to view the file modification time under the Linux related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this Linux how to view the file modification time article will have a harvest, let's take a look.

You can use stat command, date command, ls-l command, httpie and so on to check the file modification time in Linux system. 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 fileDevice: fd00h/64768d Inode: 67169379 Links: 1Access: (0755/-rwxr-xr-x) Uid: (0 / root) Gid: (0 / root) Context: unconfined_u:object_r:admin_home_t:s0Access: 2020-10-15 19:13: 24.628009932 + 0800Modify: 2020-10-15 19V 07VR 18.266426499 + 0800Change: 2020-10-1519V 11V 48.227856412 + 0800Birth:-

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.sh2020-10-15 19 hello_script.sh2020 07purl 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.shThu 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-ttotal 288drwxr-xr-x. 2 root root 177 Oct 16 14:36 bdrwxr-xr-x. 2 root root 177 Oct 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.txtdrwxr-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

This is the end of the article on "how to check the file modification time under Linux". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to check the file modification time under Linux". If you want to learn more, you are 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

Development

Wechat

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

12
Report