linux find命令忽略目录的查找方法,linuxfind


本文介绍了linux下find命令的特殊用法,在查找文件时忽略目录的方法,find命令忽略目录查找的实例教程,需要的朋友可以参考下

在linux操作系统中,find命令非常强大,在文件与目录的查找方面可谓无所不至其极,如果能结合xargs命令使得,更是强大无比。

以下来看看find命令忽略目录查找的用法吧。

例1,根据文件属性查找:


代码如下:

find . -type f -name "*config*" ! -path "./tmp/*" ! -path "./scripts/*" ! -path "./node_modules/*"
Explanation:
find . - Start find from current working directory (recursively by default)
-type f - Specify to find that you only want files in the results
-name "*_peaks.bed" - Look for files with the name ending in _peaks.bed
! -path "./tmp/*" - Exclude all results whose path starts with ./tmp/
! -path "./scripts/*" - Also exclude all results whose path starts with ./scripts/

例2,根据文件内容查找:


代码如下:

grep -n -r --exclude-dir='node_modules' --exclude-dir='logs' --exclude="nohup.out" 192 *


当前大家也可以参考这篇文章:linux find命令忽略某个或多个子目录的实例


linux命令 find找一个文件 只在当前目录找? 想整个电脑的找 怎办?

比如查找文件 kk

全盘搜索方法为 find (空格) / (空格) kk 即是find / kk
当前目录搜索 find . kk
制定路径搜索,比如指定搜索xq文件夹 find /xq kk

谢谢,记得每个参数后都有空格~
 

linux操作系统利用find 命令怎查找某个目录的位置

find / -name 文件名 就有了