LX0-103 · Question #17
In a nested directory structure, which find command line option would be used to restrict the command to searching down a particular number of subdirectories?
The correct answer is B. -maxdepth. The find command uses -maxdepth to limit how many directory levels deep the search will descend from the starting point.
Question
In a nested directory structure, which find command line option would be used to restrict the command to searching down a particular number of subdirectories?
Options
- A-dirmax
- B-maxdepth
- C-maxlevels
- D-n
- E-s
How the community answered
(18 responses)- B94% (17)
- D6% (1)
Why each option
The find command uses -maxdepth to limit how many directory levels deep the search will descend from the starting point.
-dirmax is not a valid find option and will cause find to report an unknown predicate error.
The -maxdepth option is the valid find predicate that restricts directory traversal to the specified number of levels. For example, -maxdepth 1 searches only the starting directory, and -maxdepth 2 includes one level of subdirectories. It is a standard GNU find option documented in the find man page.
-maxlevels is not a valid find option - the correct option name is -maxdepth.
-n is not a depth-limiting option for find; it has no defined meaning in this context.
-s is not a depth-limiting option for find and does not restrict directory traversal.
Concept tested: find command depth restriction with -maxdepth
Source: https://man7.org/linux/man-pages/man1/find.1.html
Topics
Community Discussion
No community discussion yet for this question.