HomeUNIXLimit the depth of search using find

Limit the depth of search using find

The find command searches all subdirectories under the specified path by default. Using the maxdepth option, the search depth can be limited.


To run a find command limited to only the current directory and not search through any subdirectories, use the -maxdepth 0 option:

find . -maxdepth 0 -print

To search one level of directories below /usr, use:

find /usr -maxdepth 1 -print

The maxdepth option can be used in conjunction with other find options such as -name, -nouser, -atime, etc.

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!