In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you about Linux how to view the time when the file was modified. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
Use the stat command stat command to display the detailed information of the file attributes, such as the time when the file was last 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 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.
The use of the date command 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
Using the ls-l command ls-l command is typically used to use a long list to display other information about the 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:
After the $sudo apt install httpie 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
These are all the contents of the article "how to check the time when files were modified by Linux". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.