Chinaunix

标题: linux中怎么删除一天之前的目录 [打印本页]

作者: lddlww    时间: 2016-05-12 09:35
标题: linux中怎么删除一天之前的目录
linux中怎么删除一天之前的目录?或者指定日期的目录?
作者: shenyue_sam    时间: 2016-05-12 09:39
find . -mtime -1 -exec rm -f {} \;
作者: lddlww    时间: 2016-05-12 09:45
这个是删除目录的?回复 2# shenyue_sam


   
作者: shenyue_sam    时间: 2016-05-12 09:51
这样应该可以
find . -type d -mtime -1 -exec rm -rf {} \;
作者: lyhabc    时间: 2016-05-12 19:01

dir="/tmp"
find $dir -type d -mtime +1 |xargs -i rm -rf {}
作者: lddlww    时间: 2016-05-13 10:44
回复 5# lyhabc


    3Q
作者: lddlww    时间: 2016-05-13 10:45
回复 5# lyhabc


    问下版主,atime,ctime,mtime有什么区别?
作者: cjfeii    时间: 2016-05-13 11:16
  1. man find
  2. -atime n
  3.               File was last accessed n*24 hours ago.  When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.
  4. -ctime n
  5.               File's status was last changed n*24 hours ago.  See the comments for -atime to understand how rounding affects the interpretation of file status change times.
  6. -mtime n
  7.               File's data was last modified n*24 hours ago.  See the comments for -atime to understand how rounding affects the interpretation of file modification times.
复制代码
回复 7# lddlww


   
作者: lyhabc    时间: 2016-05-13 16:52
@lddlww
modification time(mtime)
当该文件的“内容数据”更改时,就会更新这个时间。 内容数据指的是文件的内容,而不是文件的属性或权限。

status time(ctime)
当该文件的“状态”(status)改变时,就会更新这个时间。举例来说,像是权限与属性被更改了,都会更新这个时间。

access time(atime)
当“该文件的内容被取用”时,就会更新这个读取时间(access)。举例来说,我们使用cat去读取/etc/man.config,就会更新该文件的atime了。
作者: shang2010    时间: 2016-05-13 21:43
各位都是shell大牛啊,基本功可以的嘛
作者: shang2010    时间: 2016-05-13 21:44
各位都是shell大牛啊,基本功可以的嘛




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