nerdexam
LPI

010-100 · Question #64

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

The correct answer is A. find . -name MyFile.xml. This question tests knowledge of the Linux 'find' command for recursively locating a file by name starting from the current directory.

Finding Your Way on a Linux System

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 ./

How the community answered

(57 responses)
  • A
    84% (48)
  • B
    2% (1)
  • C
    2% (1)
  • D
    7% (4)
  • E
    5% (3)

Why each option

This question tests knowledge of the Linux 'find' command for recursively locating a file by name starting from the current directory.

Afind . -name MyFile.xmlCorrect

The command 'find . -name MyFile.xml' uses the 'find' utility with '.' as the starting path (current directory) and the '-name' predicate to match files by exact filename. The find command traverses all subdirectories recursively by default, making this the correct and standard approach.

Bgrep MyFile.xml | find

This is invalid syntax - grep searches file contents for text patterns and cannot be piped into find in this form to locate files by name.

Cgrep -r MyFile.xml .

'grep -r MyFile.xml .' recursively searches inside files for the text string 'MyFile.xml', not for a file whose name is MyFile.xml.

Dless MyFile.xml

'less MyFile.xml' opens a known file path in a pager for viewing its contents and performs no directory search.

Esearch Myfile.xml ./

'search' is not a standard Linux command and this syntax would produce a command-not-found error on a typical Linux system.

Concept tested: Linux find command recursive file name search

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

Topics

#find command#file search#directory traversal

Community Discussion

No community discussion yet for this question.

Full 010-100 Practice