在linux操作系統(tǒng)中,find命令非常強(qiáng)大,在文件與目錄的查找方面可謂無(wú)所不至其極,如果能結(jié)合x(chóng)args命令使得,更是強(qiáng)大無(wú)比。
以下來(lái)看看find命令忽略目錄查找的用法吧。
例1,根據(jù)文件屬性查找:
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,根據(jù)文件內(nèi)容查找:
grep -n -r --exclude-dir='node_modules' --exclude-dir='logs' --exclude="nohup.out" 192 *
當(dāng)前大家也可以參考這篇文章:linux find命令忽略某個(gè)或多個(gè)子目錄的實(shí)例