在Linux终端,如何显示文件夹的最后修改时间,利用其内容纳入考虑? [英] in linux terminal, how do I show the folder's last modification date, taking its content into consideration?
本文介绍了在Linux终端,如何显示文件夹的最后修改时间,利用其内容纳入考虑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以这里的交易。比方说,我有一个名为网目录,所以
So here's the deal. Let's say I have a directory named "web", so
$ ls -la
drwx------ 4 rimmer rimmer 4096 2010-11-18 06:02 web
但这个目录,网页/ PHP的内部/
BUT inside this directory, web/php/
$ ls -la
-rw-r--r-- 1 rimmer rimmer 1957 2011-01-05 08:44 index.php
这意味着,即使我的目录的内容,/web/php/index.php已经在最后修改2011-01-05,到/ web /目录本身被报告为最后的修改2010-11-18
That means that even though the content of my directory, /web/php/index.php has been last modified at 2011-01-05, the /web/ directory itself is reported as last modified at 2010-11-18.
我需要做的是有我的/ web /目录的最后修改日期报告该目录内的任何文件/目录的最新修改日期,递归什么。
What I need to do is have my /web/ directory's last modification date reported as the latest modification date of any file/directory inside this directory, recursively.
我如何去这样做?
推荐答案
是这样的:
find /path/ -exec stat \{} --printf="%y\n" \; |
sort -n -r |
head -n 1
说明:
- find命令将打印修改时间为每个文件递归
- 排序-n(数字)-r(反向)
- 头-n 1:获得第一项
这篇关于在Linux终端,如何显示文件夹的最后修改时间,利用其内容纳入考虑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文