Chinaunix

标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12 [打印本页]

作者: shootero    时间: 2002-04-24 09:09
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12

作者: valentine    时间: 2002-04-24 09:48
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
创建一个脚本judgetime,内容如下:

ls -l $*|awk '{split($8,hour,&quot;:&quot;if((hour[1]>23 || hour[1] < 1)&amp;&amp;hour[1]<24)print}'

到要查找的目录下,运行
find ./ -name &quot;*&quot; -exec judgetime {} \;

注意时间格式为24小时制。




作者: shootero    时间: 2002-04-24 10:02
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
thank you ,如果我要精确到分钟呢
作者: 仓库保管员    时间: 2002-04-24 10:08
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
touch -t 04241112 starttemp  #精确到12分钟
touch -t 04241220 endtemp  #截止到12点20
find [dir] -newer starttemp -a ! -newer endtemp -exec ls -l {} \;
作者: valentine    时间: 2002-04-24 10:16
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
newer?
那昨天12:10文件如何呢?
作者: shootero    时间: 2002-04-24 10:32
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
谢谢大家的帮助。
作者: 仓库保管员    时间: 2002-04-24 10:33
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
每天执行的时候,用当天的日期和时间戳替换一下不就行了吗?
我不知道他是不是把所有的11:00~12:00的都找出来,是不是只执行一次还是每天都执行?
作者: valentine    时间: 2002-04-24 10:36
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
这种情况俺猜想是自己的东西放在哪忘了,只记得当时是深夜了。
作者: 仓库保管员    时间: 2002-04-24 10:38
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
有道理!
不愧是斑竹!
不光知道怎么解决问题,还知道在什么情况下出现这类问题,佩服佩服!
作者: shootero    时间: 2002-04-24 10:52
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
问题又出现了。创建这个文件的时候。本来应该是时间的一栏现在写上了2002,而不是12:00.
作者: 仓库保管员    时间: 2002-04-24 11:51
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
等到12:00过了吧!
作者: penda    时间: 2003-06-17 22:16
标题: 请问,使用find 命令查找某个时间段的shell怎么写。比如11点到12
创建一个脚本judgetime,内容如下:

ls -l $*|awk '{split($8,hour,":";if((hour[1]>23 || hour[1] < 1)&&hour[1]<24)print}'

为什么split函数返回的数组hour不能用printf("%s",hour)这样的形式打印出来,只能printf("%d",hour[1]),printf("%d",hour[2])这样来打印。

请高手请教返回的数组是什么类型的!
作者: rishairu    时间: 2008-04-24 14:36
虽然是2002年写的东西,但是现在也是很有参考价值地
作者: 一刀砍死    时间: 2008-08-20 10:19
不错不错,学习ing.
作者: bigqueues    时间: 2008-08-20 15:40
汗,这么老的贴……
这年头流行翻老贴啊
作者: wstar    时间: 2008-08-20 22:57
学习了。真不错。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2