请问,如何用find找出指定日期的文件,比如找出2004年4月的文件

sh/bash/dash/ksh/zsh等Shell脚本
回复
newmcse
帖子: 3
注册时间: 2008-04-15 2:24

请问,如何用find找出指定日期的文件,比如找出2004年4月的文件

#1

帖子 newmcse » 2008-04-15 2:26

请问,如何用find找出指定日期的文件,比如找出2004年4月的文件,比如我写一个script, 输入200405,则找到所有2004年5月的文件?
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#2

帖子 eexpress » 2008-04-15 9:14

touch2个日期的文件
然后用
-cnewer
-anewer
-newer
找中间的。

日期有几种的。自己注意下。
● 鸣学
newmcse
帖子: 3
注册时间: 2008-04-15 2:24

#3

帖子 newmcse » 2008-04-15 12:39

touch 不是格式要YYYYMMDDhhmm吗?如何光输入YYYYMM呢?
bubbi
帖子: 5
注册时间: 2008-04-17 1:47

#4

帖子 bubbi » 2008-04-21 11:05

ls -al |grep 200405 不行吗?
newbie
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

#5

帖子 bones7456 » 2008-04-22 17:35

newmcse 写了:touch 不是格式要YYYYMMDDhhmm吗?如何光输入YYYYMM呢?
touch要的是 [[CC]YY]MMDDhhmm[.SS] ,其他的用0代替嘛
关注我的blog: ε==3
justlook
帖子: 5
注册时间: 2008-04-27 18:45

#6

帖子 justlook » 2008-04-27 21:08

#!/bin/bash
read -p "input u date(use format:YYYY-MM-DD) " a
echo "u choose $a"
read -p "input the path which u look for" path


find $path -name "*" -type f|xargs -I @ ls -l @>temp
awk -v var=$a '{if($6==var)print $6" "$8}' temp

exit 0
回复