LFCS · Question #830
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 the -maxdepth option to limit the search to a specified number of subdirectories below the starting point, preventing it from traversing deeper into the directory tree.
Question
Options
- A-dirmax
- B-maxdepth
- C-maxlevels
- D-n
- E-s
How the community answered
(67 responses)- A7% (5)
- B87% (58)
- C4% (3)
- E1% (1)
Why each option
The `find` command uses the `-maxdepth` option to limit the search to a specified number of subdirectories below the starting point, preventing it from traversing deeper into the directory tree.
`dirmax` is not a valid or standard option for the `find` command to restrict search depth.
The `-maxdepth` option for the `find` command specifies the maximum number of levels of directories that `find` will descend. For example, `-maxdepth 1` would only search the starting directory and no subdirectories.
`maxlevels` is not a valid or standard option for the `find` command to restrict search depth.
The `-n` option for `find` is not used for limiting search depth; it's often used with other commands for line numbering or similar purposes.
The `-s` option for `find` is not used for limiting search depth; it's typically used for silent mode or for sorting results depending on the command.
Concept tested: Find command directory depth restriction
Source: https://man7.org/linux/man-pages/man1/find.1.html
Topics
Community Discussion
No community discussion yet for this question.