nerdexam
Exams010-160Questions#62
LPI

010-160 · Question #62

010-160 Question #62: Real Exam Question with Answer & Explanation

The correct answer is A: find . -name MyFile.xml. The find command with a starting path of dot and the -name predicate recursively locates files by filename in the current directory tree.

Question

How can the current directory and its subdirectories be searched for the file named MyFile.xml?

Options

  • Afind . -name MyFile.xml
  • Bgrep MyFile.xml | find
  • Cgrep -r MyFile.xml.
  • Dless MyFile.xml
  • Esearch MyFile.xml ./

Explanation

The find command with a starting path of dot and the -name predicate recursively locates files by filename in the current directory tree.

Common mistakes.

  • B. grep searches file contents for text patterns, not filenames; piping to find with no arguments is also invalid syntax.
  • C. grep -r searches inside files recursively for the string 'MyFile.xml' as content, not for a file bearing that name.
  • D. less is a terminal pager for viewing the contents of a known file; it does not traverse the filesystem looking for files by name.
  • E. search is not a standard Unix or Linux command; this syntax does not exist in a default shell environment.

Concept tested. Using find to locate files by name recursively

Reference. https://www.gnu.org/software/findutils/manual/html_mono/find.html

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice