Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use find command to ignore directory in linux

Shulou Source: shulou.com Published: 2022-06-01 14:50:04 11月15日 Update

How to use the find command to ignore the directory in linux, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this to learn, I hope you can gain something.

Example 1: Search according to file attributes:

The code is as follows:

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/

Example 2: Search for:

The code is as follows:

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

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Tags: Code content documents help commands directories clear for this attributes articles novices more knowledge industry information information channels problems requirements channels enter one Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info vpn Apple MariaDB Xiaomi