CompTIA Linux+ (XK0-004) — Question 194

A Linux administrator wants to obtain a list of files and subdirectories in the /etc directory that contain the word `services`. Once the files and subdirectories are discovered, they should be listed alphabetically in the /var/tmp/foundservices file. Which of the following shell scripts will accomplish this task?

Answer options

Correct answer: A

Explanation

The correct answer is A because it uses the 'find' command to search for files named 'services' in the /etc directory and then sorts the results before redirecting them to the specified file. Option B incorrectly uses 'locate', which does not search for files in the way required, while C lacks the correct parameters to find files in the /etc directory. D is incorrect as it misses the proper use of the 'sort' command, which should follow the output redirection.