查看: 250|回复: 0

[教程] linux find命令忽略目录的查找方法

[复制链接]

3

主题

0

回帖

9

积分

技术1级

金币
6
阅读权限
10
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2011-1-5
QQ
发表于 2012-2-22 07:43:42 | 显示全部楼层 |阅读模式
在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命令忽略某个或多个子目录的实例
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部