您的位置:首页 > 编程语言 > Qt开发

按照 access/modify/change time 来给文件排序 --- 我的秘笈:)

2012-04-27 13:58 489 查看
ls -lrt  //按照 modify time 排序, 而且显示出来的是 modify time !

ls -lut  //按照 access time 排序, 而且显示出来的时间也是access time!   // ls --time=u -lrth 效果一样!   // 'u'可以理解为use,access的意思

ls -lc  //显示 change time !!! 但是不会排序!

ls --time=c -lrth --full-time   //显示 change time !!! 并且会排序!

通过下面的例子来验证 ls --time=c -lrth 确实是按照change time来排序的:

[wyh@ qt-everywhere-opensource-src-4.7.4 12:22:25]$ls -lc | awk '{print $6,$7,$8,$9}' | sort > /tmp/ls_lc_sorted.txt

[wyh@ qt-everywhere-opensource-src-4.7.4 12:22:46]$ls --time=c -lrth | awk '{print $6,$7,$8,$9}' > /tmp/ls_time-c_lrth.txt

[wyh@ qt-everywhere-opensource-src-4.7.4 23:30:07]$ls -lut //按照 access time 排序, 而且显示出来的时间也是access time!

    ... ...

-rw-r--r--.  1 wyh wyh    6962 Apr 26 06:30 projects.pro

-rw-rw-r--.  1 wyh wyh   39482 Apr 26 06:27 configure_qt_hi3716H-4.7.4-0426A.log

-rw-rw-r--.  1 wyh wyh 4518391 Apr 26 01:40 gmake_qt_hi3716H-4.7.3.0425A.log

-rw-rw-r--.  1 wyh wyh   79894 Apr 26 01:37 configure_qt_hi3716H-4.7.3.0425A.log

-rwxr-xr-x.  1 wyh wyh  303459 Apr 26 01:37 configure_ori

-rwxr-xr-x.  1 wyh wyh  303509 Apr 26 01:35 configure

[wyh@ qt-everywhere-opensource-src-4.7.4 10:20:12]$stat -c %x configure

2012-04-26 01:35:30.760510811 +0800

[wyh@ qt-everywhere-opensource-src-4.7.4 10:20:34]$stat -c %x gmake_qt_hi3716H-4.7.3.0425A.log

2012-04-26 01:40:29.345310823 +0800

[wyh@ qt-everywhere-opensource-src-4.7.4 10:20:56]$

[wyh@ qt-everywhere-opensource-src-4.7.4 10:22:20]$ls -lrt  //按照 modify time 排序, 而且显示出来的是 modify time !

 ... ...

drwxr-xr-x. 29 wyh wyh    4096 Apr 26 14:53 src

drwxr-xr-x.  7 wyh wyh    4096 Apr 26 22:06 config.tests

drwxr-xr-x.  3 wyh wyh    4096 Apr 26 22:09 qmake

drwxr-xr-x. 99 wyh wyh    4096 Apr 26 22:09 mkspecs

-rw-rw-r--.  1 wyh wyh  100385 Apr 26 22:11 Makefile

-rwxrwxr-x.  1 wyh wyh    1095 Apr 26 22:12 config.status

-rw-rw-r--.  1 wyh wyh   96266 Apr 26 22:12 configure_qt_hi3716H-4.7.4-0426B.log

drwxr-xr-x.  4 wyh wyh    4096 Apr 27 02:27 lib

drwxr-xr-x.  2 wyh wyh    4096 Apr 27 02:33 bin

drwxr-xr-x.  4 wyh wyh   12288 Apr 27 02:34 translations

-rw-rw-r--.  1 wyh wyh 8515978 Apr 27 02:34 gmake_qt_hi3716H-4.7.4-0426B.log

[wyh@ qt-everywhere-opensource-src-4.7.4 10:24:12]$stat -c %y gmake_qt_hi3716H-4.7.4-0426B.log

2012-04-27 02:34:07.436353825 +0800

[wyh@ qt-everywhere-opensource-src-4.7.4 10:24:55]$stat -c %y configure_qt_hi3716H-4.7.4-0426B.log

2012-04-26 22:12:00.228094082 +0800

[wyh@ qt-everywhere-opensource-src-4.7.4 10:25:07]$

[wyh@ qt-everywhere-opensource-src-4.7.4 10:31:17]$ls -lc //显示 change time !!!

 ... ...

drwxr-xr-x.  7 wyh wyh    4096 Apr 27 03:40 config.tests

-rw-rw-r--.  1 wyh wyh   39482 Apr 26 02:08 configure_qt_hi3716H-4.7.4-0426A.log

-rw-rw-r--.  1 wyh wyh   96266 Apr 26 22:12 configure_qt_hi3716H-4.7.4-0426B.log

-rw-rw-r--.  1 wyh wyh   41276 Apr 25 04:05 gmake_0425_4:02.log

-rw-rw-r--.  1 wyh wyh 4518391 Apr 25 15:02 gmake_qt_hi3716H-4.7.3.0425A.log

-rw-rw-r--.  1 wyh wyh 8515978 Apr 27 02:34 gmake_qt_hi3716H-4.7.4-0426B.log

-rw-rw-r--.  1 wyh wyh     498 Apr 13 19:33 hisi_env.sh

 ...

drwxr-xr-x. 28 wyh wyh    4096 Apr 27 03:40 tools

drwxr-xr-x.  4 wyh wyh   12288 Apr 27 03:40 translations

[wyh@ qt-everywhere-opensource-src-4.7.4 10:32:19]$stat -c %z gmake_qt_hi3716H-4.7.4-0426B.log //change time

2012-04-27 02:34:07.436353825 +0800

[wyh@ qt-everywhere-opensource-src-4.7.4 10:32:56]$stat -c %z translations  //change time

2012-04-27 03:40:34.233784396 +0800

[wyh@ qt-everywhere-opensource-src-4.7.4 10:33:14]$stat -c %y translations  //modify time

2012-04-27 02:34:07.000000000 +0800

[wyh@ qt-everywhere-opensource-src-4.7.4 10:33:19]$

  ========================== ls -lut 的增强: ls --time=u -lrth --full-time    //按照 access time 排序

 

[wyh@ qt-everywhere-opensource-src-4.7.4 12:31:26]$ls --time=u -lrth --full-time

  。。。

-rw-rw-r--.  1 wyh wyh  79K 2012-04-27 12:05:51.432861537 +0800 configure_qt_hi3716H-4.7.3.0425A.log

-rw-rw-r--.  1 wyh wyh  39K 2012-04-27 12:05:51.578861612 +0800 configure_qt_hi3716H-4.7.4-0426A.log

-rw-rw-r--.  1 wyh wyh 4.4M 2012-04-27 12:08:11.834919040 +0800 gmake_qt_hi3716H-4.7.3.0425A.log

-rw-rw-r--.  1 wyh wyh 8.2M 2012-04-27 12:08:13.348162023 +0800 gmake_qt_hi3716H-4.7.4-0426B.log

-rw-r--r--.  1 wyh wyh 6.8K 2012-04-27 12:08:23.106280559 +0800 projects.pro

[wyh@ qt-everywhere-opensource-src-4.7.4 12:31:26]$stat -c %x projects.pro  //access time

2012-04-27 12:08:23.106280559 +0800

[wyh@ qt-everywhere-opensource-src-4.7.4 12:33:24]$

 ===========================  解释下前面用到的 stat 命令:

 

 用 stat -c %x(%y, %z) xxxfile  分别获取:  access/modify/change time

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  qt access c