linux find 样例

一、语法

find [directories] [expression]

 

二、参数说明

-name pattern // pattern 为待查找文件配置格式,允许使用通配符,通配符前需要加转义字符如, \*,\?

-type t // t 可为 f (文件),d (目录),l (符号连接),b (块设备), c (字符设备), p (命名管道), s (套接字)

-print // 打印到指定文件的相对路径

 

三、例子

1)全目录下查找指定文件 myfile

$ find / -type f -name myfile -print

2)打印所有目录名

$ find / -type d -print

3)打印 以 .txt 结尾的所有文件

$ find / -type f -name \*.txt -print

4)查找包含指定字符串(mywords)的文件

$ find . -print | xargs grep -l mywords
posted @ 2015-05-04 17:02  阿青1987  阅读(171)  评论(0编辑  收藏  举报