Get the App
SLTechnology News&Howtos  ›  Servers  › 

How linux looks at the last few lines of data in a file

Shulou Source: shulou.com Published: 2022-05-31 22:43:35 09月16日 Update

This article mainly introduces "linux how to view the last few lines of data in the file". In daily operation, I believe many people have doubts about how to view the last few lines of data in the file by linux. The editor consulted all kinds of information and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubts of "how to view the last few lines of data in the file by linux". Next, please follow the editor to study!

In linux, you can use the tail command to view the last few lines of data, which is used to view the tail of the file; simply execute the "tail-n line value filename" command to view the specified number of lines of data from the end of the file.

The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

Linux looks at the last few lines of data in the file

Use the tail command

To view the last few lines of data in the file, you can use:

Tail-n row value filename

Example: tail-n 20 filename

Can display the last 20 lines of filename

Description:

The tail command is used to view the tail content in the file. The tail command displays the last 10 lines of the specified file on the screen by default. If more than one file is given, each file displayed is preceded by a file name title. If no file is specified or the file name is "-", standard input is read.

Note: if the N value indicating the number of bytes or lines is preceded by a "+" sign, it is displayed from the N item at the beginning of the file instead of the last N item of the file. The N value can be followed by a suffix: B for 512, k for 1024, m for 1, 048576 (1m).

Syntax format:

Tail [parameters] [file]

Parameters:

-f loop read

-Q does not display processing information

-v displays detailed processing information

Number of bytes displayed by-c

-n displays the contents of the last n lines of the file

-- pid=PID is used with-f to indicate that it ends after the process ID,PID dies.

-Q,-- quiet,-- silent never outputs the first part of the given file name

-s,-- sleep-interval=S is used with-f to indicate dormancy for S seconds at intervals of each iteration.

At this point, the study on "how to view the last few lines of data in a file by linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: File data command learning content tail information parameter byte numeric value file name more end processing help utility and then never function suffix Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Information MariaDB Huawei macOS