LinuxSir.cn,穿越时空的Linuxsir!

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

JavaLee 请进

[复制链接]
发表于 2004-5-21 23:28:46 | 显示全部楼层 |阅读模式
发表于 2004-5-22 00:02:27 | 显示全部楼层
试试这个吧: find -type f -printf "%Ay %f\n"
list所有04年之后的file. find -type f -printf "%Ay %f\n" -exec mv {} ./dir \; 将它们移到别的folder, 剩下不就都是04年以前的了.
 楼主| 发表于 2004-5-22 00:05:12 | 显示全部楼层
能不能详细点, 我看你的语句没有指明2004的参数, 也没有标出移到哪个目录。。
不懂shell, 所以麻烦详细一点。
发表于 2004-5-22 00:21:25 | 显示全部楼层
find -type f \! -name "dir" -printf "%Ay %f\n" -exec mv {} test \; 2>/dev/null
这样会更好一些. \! -name "dir" 表示不包括你要copy到的那个目录.这样就不会有错了.
发表于 2004-5-22 00:27:12 | 显示全部楼层
find -type f \! -name "test" -printf "%Ay %f\n" | awk '{ if($1>=04)print $2}' | xargs -ti mv {} test 2>/dev/null
哦,对不起,忘了年份的限制了. -printf "%Ay %f"是表示打印出年份和文件名. 然后pipe到awk来判断, 最后pipe到xargs 来move.
发表于 2004-5-22 00:39:08 | 显示全部楼层
嗯, 用Y比y要更保险点, 如果你有2000年以下的文件."%AY %f\n"
发表于 2004-5-22 06:41:22 | 显示全部楼层
touch建立一个文件,时间是2004-1-1。
然后find -cnewer。

-cnewer file
File's status was last changed more recently than file was modified. -cnewer is affected by -follow only if -follow comes before -cnewer on the command line.

-newer file
File was modified more recently than file. -newer is affected by -follow only if -follow comes before -newer on the command line
发表于 2004-5-22 09:14:01 | 显示全部楼层
学到东西了。:cool:
黯然兄的方法比较好。可以在HOME目录里touch一个文件再对目标目录进行find,充分利用find的日期比较功能。
 楼主| 发表于 2004-5-22 13:30:03 | 显示全部楼层
你们看懂了, 俺还没有。
发表于 2004-5-22 15:10:28 | 显示全部楼层
用lftp登录试试看,因为lftp支持shell命令
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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