乐闻世界logo
搜索文章和话题

What is the tail command in Linux? How can you display the last 10 lines of a file using 'tail'?

1个答案

1

The tail command in Linux is used to display the last few lines of a file, which is very useful for viewing the latest updates in large log files.

To display the last 10 lines of a file using tail, you can use the following command:

bash
tail -n 10 filename

The -n parameter specifies the number of lines to display, 10 indicates the last 10 lines, and filename is the name of the file you want to view.

For example, if you have a file named log.txt and you want to view its last 10 lines, you can use:

bash
tail -n 10 log.txt

This command outputs the last 10 lines of the log.txt file. If you do not specify the -n parameter, the tail command defaults to displaying the last 10 lines. Therefore, simply using tail filename will yield the same result.

2024年8月14日 13:06 回复

你的答案