美文网首页
删除 N 天前文件

删除 N 天前文件

作者: Alexander_Zz | 来源:发表于2020-01-03 14:12 被阅读0次

    ~]# find /PATH/TO/SOMEFILES/ -type f -name '*.txt' -mtime +N -exec rm {} \;
    
    • -type f:指定查找的为文件,而非文件夹或文件链接等
    • -name '*.txt': 指定查找的文件名的模式
    • -mtime: 指定文件的修改时间,以天为单位。+N 是 N 天以前,-N 是 N 天以内,N 是第 N 天。另外有,-mmin 按分钟为单位指定文件的修改时间。还另外可以另外的参数指定文件上次使用的时间等。
           -type c
                  File is of type c:
    
                  b      block (buffered) special
    
                  c      character (unbuffered) special
    
                  d      directory
    
                  p      named pipe (FIFO)
    
                  f      regular file
    
                  l      symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is  bro‐
                         ken.  If you want to search for symbolic links when -L is in effect, use -xtype.
    
                  s      socket
    
                  D      door (Solaris)
    

    相关文章

      网友评论

          本文标题:删除 N 天前文件

          本文链接:https://www.haomeiwen.com/subject/aymhvctx.html