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小時修改的文件