[ 永远的UNIX::UNIX技术资料的宝库 ]

首页 > 编程技术 > 源码天堂 > 正文
Shell源码:find查找日期为某一天的文件
本文出自:news://news.freesoft.cei.gov.cn/chinese.com.linux 作者: 宫敏 (2001-08-24 12:00:00)
   A=`find ~ -print` | ls -l --full-time $A 2>/dev/null | grep "Jun 27"  | grep 1998 
   Linux的命令很厉害的呀! 
   给你写了下面这个script,用着方便点儿。你把它存成一个随便什么名字的文件,置上x属性就行了。 
   #!/bin/sh 
   # Copyright by Ming Gong(宫敏) for news://news.freesoft.cei.gov.cn/chinese.com.linux 
   # GPL V2, Jun 30, 1998 
   # The right of usage, distribution and modification is here by granted by the author. 
   # The author deny any responsibilities and liabilities related to the code. 
   # 
   OK=0 
   A=`find $1 -print` 
   if expr $3 == 1 >/dev/null  ; then M=Jan ; OK=1 ; fi 
   if expr $3 == 2 >/dev/null  ; then M=Feb ; OK=1 ; fi 
   if expr $3 == 3 >/dev/null  ; then M=Mar ; OK=1 ; fi 
   if expr $3 == 4 >/dev/null  ; then M=Apr ; OK=1 ; fi 
   if expr $3 == 5 >/dev/null  ; then M=May ; OK=1 ; fi 
   if expr $3 == 6 >/dev/null  ; then M=Jun ; OK=1 ; fi 
   if expr $3 == 7 >/dev/null  ; then M=Jul ; OK=1 ; fi 
   if expr $3 == 8 >/dev/null  ; then M=Aug ; OK=1 ; fi 
   if expr $3 == 9 >/dev/null  ; then M=Sep ; OK=1 ; fi 
   if expr $3 == 10 >/dev/null  ; then M=Oct ; OK=1 ; fi 
   if expr $3 == 11 >/dev/null  ; then M=Nov ; OK=1 ; fi 
   if expr $3 == 12 >/dev/null  ; then M=Dec ; OK=1 ; fi 
   if expr $3 == 1 >/dev/null  ; then M=Jan ; OK=1 ; fi 

   if expr $OK == 1 > /dev/null ; then 
     ls -l --full-time $A 2>/dev/null | grep "$M $4" | grep $2 ; 
   else 
     echo Usage: $0 path Year Month Day; 
     echo Example: $0 ~ 1998 6 30; 
   fi 
 

 

(http://www.fanqiang.com)
    进入【UNIX论坛

相关文章
C源码:通过IP地址查找主机名 findip.c (2001-10-14 13:05:00)
Shell源码:用命令find产生一个以当日日期为后缀的文件 (2001-08-24 15:00:01)
Shell源码:find查找日期为某一天的文件 (2001-08-24 12:00:00)
解决libxxxx.so : not find 找不到的问题 (2001-06-29 11:00:00)
如何用 find 命令进行灵活查找 (2001-06-29 10:08:00)
Linux 指令篇:档案目录管理--find (2001-04-30 14:03:28)
技巧:利用Find命令改变所有权 (2001-04-15 21:32:32)
 

★  樊强制作 欢迎分享  ★