LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 819|回复: 2

a newbie's question: how to find files modified in a date range

[复制链接]
发表于 2008-9-29 17:11:46 | 显示全部楼层 |阅读模式
hi all,
     could someone tell me how to find out files modified in a date range  under a directory?     
   
     i'm trying to write a simple shell script to see if i'm still a newbie here, and finally the result convinced me that i am !   

    these are my foot steps,

intention:   print out file names which are modified during a date range.

    1. i want to display file names that are modified from 2007.01.01 to

2008.01.01  ,  so i created 2 files and compared each file in current

directory with them.

            $ touch tempstart -t 200701010000
            $ touch tempend  -t 200801010000

    2.  then using them to fileter out file modified between 2007.01.01 and                 2008.01.01
           $ find . -cnewer tempstart -and ! -cnewer tempend


everything sees ready , but the fact is it could not find out anything

while using "ls -lh" command to list file details,  i do see files there:

-rwxr-xr-x 1 zpxu zpxu 138M 2008-02-17 22:39 eclipse-SDK-3.3.1.1-linux-gtk.tar.gz
drwxr-xr-x 2 zpxu zpxu 8.0K 2008-02-17 23:08 exewindows
-rwxr-xr-x 1 zpxu zpxu  44M 2004-10-10 12:10 jdk150.chm
-rwxr-xr-x 1 zpxu zpxu 409K 2006-12-03 12:33 mysql-connector-java-3.1.10-bin.jar
-rwxr-xr-x 1 zpxu zpxu 388K 2006-12-16 20:29 mysqldriver.jar
drwxr-xr-x 2 zpxu zpxu 8.0K 2007-09-20 22:06 spring
-rwxr-xr-x 1 zpxu zpxu 7.1M 2007-08-10 14:37 squirrel-sql-2[1].0final-install.jar
-rwxr-xr-x 1 zpxu zpxu    0 2008-01-01 00:00 tempend
-rwxr-xr-x 1 zpxu zpxu    0 2007-01-01 00:00 tempstart
-rwxr-xr-x 1 zpxu zpxu   67 2008-09-29 14:06 test.sh
发表于 2008-9-29 17:21:39 | 显示全部楼层
then you might want -newer instead of -cnewer. Please read stat man page for file's 3 stats.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-9-29 17:49:07 | 显示全部楼层
wow, it really works as you say,

thanks a million
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表