歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> linux find命令忽略目錄的查找方法

linux find命令忽略目錄的查找方法

日期:2017/3/1 17:58:28   编辑:Linux技術

在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命令忽略某個或多個子目錄的實例

Copyright © Linux教程網 All Rights Reserved