GB | BIG5
|
| 首頁 > 編程技術 > 源碼天堂 > 正文 |
 |
| 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)
|
|
|
|
 |
★ 樊強制作 歡迎分享 ★ |