nerdexam
LPI

010-160 · Question #23

Which of the following commands will search for the file foo.txt under the directory /home?

The correct answer is D. find /home -name foo.txt. The find command uses the -name predicate to search for files by filename, requiring correct syntax with the search path first and the flag immediately preceding the pattern.

Finding Your Way on a Linux System

Question

Which of the following commands will search for the file foo.txt under the directory /home?

Options

  • Asearch /home -file foo.txt
  • Bsearch /home foo. txt
  • Cfind /home - file foo.txt
  • Dfind /home -name foo.txt
  • Efind /home foo.txt

How the community answered

(31 responses)
  • C
    3% (1)
  • D
    94% (29)
  • E
    3% (1)

Why each option

The find command uses the -name predicate to search for files by filename, requiring correct syntax with the search path first and the flag immediately preceding the pattern.

Asearch /home -file foo.txt

search is not a standard Linux utility for locating files by path; find is the correct command for this purpose.

Bsearch /home foo. txt

search is not a valid Linux command, and even a hypothetical search utility would require a flag to specify a filename rather than a bare positional argument.

Cfind /home - file foo.txt

A space between the hyphen and the word 'file' splits it into two tokens, making '- file' an unrecognized option; additionally, the correct predicate is -name, not -file.

Dfind /home -name foo.txtCorrect

The correct syntax 'find /home -name foo.txt' instructs find to begin traversal at /home and return every file whose name matches foo.txt. The -name predicate performs a case-sensitive filename comparison against each entry encountered during the recursive directory walk.

Efind /home foo.txt

Without the -name predicate, find interprets foo.txt as an additional starting path to search rather than a filename criterion, resulting in an error or incorrect behavior.

Concept tested: Linux find command -name predicate syntax

Source: https://man7.org/linux/man-pages/man1/find.1.html

Topics

#find command#file search#command syntax#path search

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice