How to view the last few lines of data in a file in Linux

青灯夜游
Release: 2021-12-02 17:54:31
Original
30076 people have browsed it

In Linux, you can use the tail command to view the last few lines of data. The purpose of this command is to view the tail content of the file; you only need to execute the "tail -n line value filename" command to view the last few lines of data from the file. View data for a specified number of rows.

How to view the last few lines of data in a file in Linux

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

Linux View the last few lines of data in the file

Use the tail command

If you want to view the file The last few lines of data can be used:

tail -n 行数值 filename
Copy after login

Example: tail -n 20 filename

can display the last 20 lines of filename

Instructions:

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, a filename header is prepended to each file displayed. If no file is specified or the file name is "-", standard input is read.

Note: If there is a " " sign before the N value indicating the number of bytes or lines, it will be displayed from the Nth item at the beginning of the file instead of the last N items of the file. The N value can be followed by a suffix: b means 512, k means 1024, and m means 1 048576 (1M).

Syntax format:

tail [参数] [文件]
Copy after login

Parameters:

  • -f Loop reading

  • -q Do not display processing information

  • -v Display detailed processing information

  • ##-c Number of bytes displayed

  • -n Display the last n lines of the file

  • --pid=PID Used with -f to indicate the process ID , ends after PID dies

  • -q, --quiet, --silent never outputs the header of the given file name

  • - s, --sleep-interval=S used in conjunction with -f, means to sleep for S seconds between each iteration

  • ##Related recommendations: "
Linux Video Tutorial

"

The above is the detailed content of How to view the last few lines of data in a file in Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template