1、在/root目录下找到大于8126464字节的文件,然后移动到/opt/hhh目录下
# find /root -type f -size +8126464c | xargs -t -i mv {} /root/hhh/
xargs:
-i 表示 find 传递给xargs的结果 由{}来代替
-t 会打印出对应的文件
find:
-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 broken. If you want to search for symbolic links when -L is in effect, use -xtype. 符号链接
s socket
D door (Solaris)
-size n[cwbkMG]选项解释:
File uses n units of space. The following suffixes can be used:
‘b’ for 512-byte blocks (this is the default if no suffix is used) 以块为单位
‘c’ for bytes 以字节单位
‘w’ for two-byte words 以单词为单位,即2哥字节
‘k’ for Kilobytes (units of 1024 bytes) 以1K为单位,即1024k
‘M’ for Megabytes (units of 1048576 bytes) 以M为单位
‘G’ for Gigabytes (units of 1073741824 bytes) 以G为单位
+8126464c的解释:
+ 表示大于8126464bytes,- 表示小于8126464bytes
2、针对文件的访问、修改等时间查找
-amin n
File was last accessed n minutes ago.
# find /root -amin -10 #查找/root目录下最后10分钟访问的文件和目录
-atime n
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.
# find /root -atime -2 #查找/root目录下最后48小时访问的目录和文件
-mmin n
File’s data was last modified n minutes ago.
# find /root -mmin -5 #查找/root目录下最后5分钟修改的文件
-mtime n
File’s data was last modified n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file modifi-
cation times.
# find /root -mtime -2 #查找/root目录下最后48小时修改的文件
转载于:https://blog.51cto.com/junlinux/1375794