删除 N 天前文件
2020-01-03 本文已影响0人
Alexander_Zz
~]# 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)