九 linux指令之find

  find命令用来在指定目录下查找文件或者目录,指令格式:

find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \

参数说明:

命令行-之前的为path,之后的是expression,如果path是空,默认在当前目录和子目录下查找,如果expression为空,默认使用print(不太明白expression),-exec应该是执行后面跟的command,-ok执行command需要用户确认是否进行,但是和 {} \是啥意思。。

查找当前路径/cc1下cc开头的文件或者目录,似乎也会查找子目录下的文件

[root@centoscc home]# find cc1 -name "cc*"
cc1
cc1/cc1
cc1/cc1/cc11
cc1/cc11

 

常用的参数

-mount,-xdev:只检查和指定目录在同一个文件系统下的文件

-amin n:在过去n min内被读过

-atime n:在过去n 天内被读过

-anewer file:比文件file更晚被读过的文件

-cmin n:在过去n min被修改过的文件

-ctime n:在过去n天被修改过

-cnewer file:比file晚更新的文件

-empty:空的文件

-gid n or group name:gid是n或者group名称

-name name:文件名称,-iname表示忽略大小写

-size n:文件大小是n,单位b表示512位元组的区块,c表示字元数,k表示kilo bytes,w是二个位元组

-type c:文件类型 d目录,c字符装置文件,b区块装置文件,f一般文件,l符号连结

-pid n:进程id

-perm:属主/组/其他用户权限

 查找权限为644的所有文件,并将文件权限数据打印出来,后面要跟“;”。

# find -perm 644 -exec ls -l {} \;

...

-rw-r--r--. 1 root root 15 12月 20 21:21 ./cc.txt
-rw-r--r--. 1 root root 16 12月 20 21:19 ./cc4.txt
-rw-r--r--. 1 root root 16 12月 22 20:36 ./root.txt
-rw-r--r--. 1 root root 16 12月 22 20:37 ./root1.txt
-rw-r--r--. 1 root root 32 12月 22 20:37 ./root2.txt
-rw-r--r--. 1 root root 4 12月 22 20:51 ./root3.txt
-rw-r--r--. 1 root root 4 12月 22 20:51 ./root4.txt

...

posted @ 2020-12-23 17:33  Cc905  阅读(87)  评论(0编辑  收藏  举报