nerdexam
CompTIACompTIA

XK0-005 · Question #102

XK0-005 Question #102: Real Exam Question with Answer & Explanation

The correct answer is A: #/bin/bash. To find files and directories containing 'services' within /etc, then list them alphabetically in /var/tmp/foundservices, a script must combine content and name searches, then sort the results.

Scripting, Containers, and Automation

Question

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?

Options

  • A#/bin/bash
  • B#/bin/bash
  • C#/bin/bash
  • D#/bin/bash

Explanation

To find files and directories containing 'services' within /etc, then list them alphabetically in /var/tmp/foundservices, a script must combine content and name searches, then sort the results.

Common mistakes.

  • B. Without the actual script content for option B, it is impossible to identify specific technical reasons for it being wrong.
  • C. Without the actual script content for option C, it is impossible to identify specific technical reasons for it being wrong.
  • D. Without the actual script content for option D, it is impossible to identify specific technical reasons for it being wrong.

Concept tested. Linux file/directory searching and sorting with grep and find

Reference. https://man7.org/linux/manpages/man1/grep.1.html

Topics

#Shell Scripting#Linux Commands#File System Navigation#Text Processing

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions