根据文件名进行搜索
[root@MIO-2 ~]# find /root/ -name "*.txt" /root/e.txt /root/.subversion/README.txt
如果想匹配多个条件中的一个,可以使用-o表示 OR
[root@MIO-2 ~]# find /root/ \( -name "*.txt" -o -name "*.sh" \) /root/e.txt /root/1.sh /root/.subversion/README.txt
根据路径的搜索
-path可将文件路径作为一个整体进行匹配
查找etc目录中nginx目录的文件
[root@MIO-2 ~]# find /etc/ -path "*/nginx/*" /etc/nginx/nginx.conf /etc/nginx/uwsgi_params.default /etc/nginx/fastcgi_params /etc/nginx/fastcgi.conf.default /etc/nginx/scgi_params /etc/nginx/fastcgi_params.default /etc/nginx/conf.d /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/virtual.conf /etc/nginx/conf.d/ssl.conf /etc/nginx/uwsgi_params /etc/nginx/win-utf /etc/nginx/mime.types /etc/nginx/fastcgi.conf /etc/nginx/koi-utf /etc/nginx/koi-win /etc/nginx/scgi_params.default /etc/nginx/mime.types.default /etc/nginx/nginx.conf.default
根据正则表达式进行搜索
要特别注意转义
[root@MIO-2 ~]# find /root/ -regex ".*\(\.sh\|\.txt\)$" /root/e.txt /root/1.sh /root/.subversion/README.txt
根据否定进行搜索
[root@MIO-2 ~]# find /root/ ! -name "*.sh" /root/ /root/e.txt