find命令:
參數:
-name file 按文件名查找
-type find ./ -type f 文件類型 (找出當前目錄小所有類型是文件 )
-exec -exec ls {} \;(find -name "123.txt" -exec ls {} \;) 後面跟命令但後面結尾時需要{}空格\;
-user find / -user root 按文件屬主查找
-group find / -group root 按文件屬組查找
-mtime -1 +1 find / -mtime -1 -name "1.*" (-1 一天以內 +1 一天以前) 按文件更改時間來修改
-atime -n +n find ./ -atmie -1 -name "1.*" (-1 一天以內 +1一天以前)按文件訪問時間查找
-ctime -n +n find ./ -ctime -1 -name "1.*" 按創建時間在一天以內的文件1.所有的文件1.* (*代表所有的意思)
-size 按文件大小查找 find ./ -size -10k -type f 查找當前小於10k的文件
查當前目錄普通文件名1.txt的文件:
[root@localhost ~]# find ./ -type f -name "1.txt"
./123/1.txt
./1.txt
查當前目錄下名爲1.txt文件並顯示出文件信息:
[root@localhost ~]# find ./ -name "1.txt" -exec ls -l {} \;
-rw-r--r--. 1 root root 2538 4月 1 13:41 ./123/1.txt
-rw-r--r--. 1 root root 889 4月 2 00:02 ./1.txt
查當前目錄下屬主是root的目錄並顯示目錄信息:
[root@localhost ~]# find ./ -type d -user root -exec ls -ld {} \;
dr-xr-x---. 3 root root 220 4月 1 13:50 ./
drwxr--r-x. 3 root root 30 4月 1 13:44 ./123
drwxr-xr-x. 2 root root 6 4月 1 12:43 ./123/234
查當前目錄下屬組是user1的目錄:
[root@localhost ~]# find ./ -group user1 -type d -exec ls -ld {} \;
drwxr-xr-x. 3 root user1 17 4月 2 00:20 ./666
drwxr-xr-x. 3 root user1 17 4月 2 00:20 ./666/777
drwxr-xr-x. 2 root user1 6 4月 2 00:20 ./666/777/888
其實find還有好多參數想了解的可以man find 裏面講的很詳細,可能最常用的就是這些,本人菜鳥一個希望大神指點