What command displays the last 10 lines of a file?

Study for the LPI Linux Essentials Exam. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

What command displays the last 10 lines of a file?

Explanation:
The command that displays the last 10 lines of a file is correctly identified as "tail -n 10 filename." The 'tail' command is specifically designed to output the last part of files, and the '-n' option allows you to specify the number of lines to display from the end. When using "-n 10," it tells the 'tail' command to show the last 10 lines of the specified file. In contrast, the other commands function differently. The first choice, "head -n 10 filename," is used to display the first 10 lines of a file, not the last. The third choice, "cat filename | head -10," involves using 'cat' to output the entire file content, then piping that output to 'head' to show the first 10 lines, which is not what is needed in this situation. Lastly, the choice "more filename" allows for paginated viewing of the file's contents but does not specifically provide just the last 10 lines, instead starting from the top of the file. Each of these commands serves distinct purposes, but only 'tail -n 10' meets the requirement of displaying the last 10 lines of a file.

The command that displays the last 10 lines of a file is correctly identified as "tail -n 10 filename." The 'tail' command is specifically designed to output the last part of files, and the '-n' option allows you to specify the number of lines to display from the end. When using "-n 10," it tells the 'tail' command to show the last 10 lines of the specified file.

In contrast, the other commands function differently. The first choice, "head -n 10 filename," is used to display the first 10 lines of a file, not the last. The third choice, "cat filename | head -10," involves using 'cat' to output the entire file content, then piping that output to 'head' to show the first 10 lines, which is not what is needed in this situation. Lastly, the choice "more filename" allows for paginated viewing of the file's contents but does not specifically provide just the last 10 lines, instead starting from the top of the file. Each of these commands serves distinct purposes, but only 'tail -n 10' meets the requirement of displaying the last 10 lines of a file.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy