Which command sequence would recursively locate all .txt files from the root directory, print each path, then display the first 10 lines of that file, separated by a blank line, while discarding errors?

Study for the OSCP Linux Exam. Use our flashcards and multiple-choice questions to test your skills. Each query comes with detailed hints and explanations to enhance your preparedness. Get ready to conquer the exam!

Multiple Choice

Which command sequence would recursively locate all .txt files from the root directory, print each path, then display the first 10 lines of that file, separated by a blank line, while discarding errors?

Explanation:
Locating and displaying content for every .txt file from root requires combining a recursive search with per-file actions: print the path, show the first 10 lines, separate entries, and hide errors. Starting the search at root with a name filter '*.txt' finds all text files you’re allowed to access. For each match, printing the path ensures you know which file is being processed. Then showing the first 10 lines uses head’s default behavior, giving a quick peek into the file without dumping its entire contents. Adding a blank line between results helps readability when there are many files. Finally, redirecting errors to /dev/null discards permission-denied or inaccessible-dir messages, so only the intended output remains. This sequence is the best fit because it performs all required steps in one command: locate, print path, display first 10 lines, separate results, and suppress errors. The other options fail to meet one or more requirements—for example, searching for the wrong name pattern or extension, not printing the file contents, or not suppressing errors—so they don’t satisfy the task as fully.

Locating and displaying content for every .txt file from root requires combining a recursive search with per-file actions: print the path, show the first 10 lines, separate entries, and hide errors.

Starting the search at root with a name filter '*.txt' finds all text files you’re allowed to access. For each match, printing the path ensures you know which file is being processed. Then showing the first 10 lines uses head’s default behavior, giving a quick peek into the file without dumping its entire contents. Adding a blank line between results helps readability when there are many files. Finally, redirecting errors to /dev/null discards permission-denied or inaccessible-dir messages, so only the intended output remains.

This sequence is the best fit because it performs all required steps in one command: locate, print path, display first 10 lines, separate results, and suppress errors. The other options fail to meet one or more requirements—for example, searching for the wrong name pattern or extension, not printing the file contents, or not suppressing errors—so they don’t satisfy the task as fully.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy