Detailed explanation of how to use the linux tail command

Show scrolling log from tail

tail -f /ebankcommon/was/ebankApp/logs/serviceController1/serviceController.log

Scroll the log from the first 200 lines from the tail

tail -f -n 200 /ebankcommon/was/ebankApp/logs/serviceController1/serviceController.log

 

This article introduces how to use the tail command in Linux.
The purpose of the linux tail command is to output the last part of the specified file to a standard device, usually a terminal. Refresh yourself to make sure you see the latest archive content.

First, the tail command syntax

tail [ -f ] [ -c Number | -n Number | -m Number | -b Number | -k Number ] [ File ]
Parameter explanation:
-f This parameter is used to monitor the growth of the File file.
-c Number Reads the specified file from Number byte positions
-n Number Reads the specified file from Number line positions.
-m Number Read the specified file from the Number multi-byte character position. For example, if your file contains Chinese characters, if you specify the -c parameter, it may cause truncation, but using -m will avoid this problem.
-b Number Reads the specified file from the 512-byte block position represented by Number.
-k Number Reads the specified file from the 1KB block position represented by Number.
File Specifies the target file name of the operation. In the
above commands, number is involved. If it is not specified, 10 lines are displayed by default. A plus or minus sign can be used in front of Number to indicate whether the offset is calculated from the top or the tail.
The tail executable file is generally under /usr/bin/.

2. Demonstration example of how to use the tail command

1. tail -f filename
Description: Monitor the tail content of the filename file (default 10 lines, which is equivalent to adding the parameter -n 10), refresh and display it on the screen. To exit, press CTRL+C.

2. tail -n 20 filename
Description: Display the last 20 lines of filename.

3. tail -r -n 10 filename
Description: Display the last 10 lines of filename in reverse order.

Supplement:
Commands similar to the tail function are:
cat Displays the contents of the file starting from the first line.
tac displays the contents of the archive starting from the last line.
The more tab displays the contents of the archive.
less is similar to more, but supports page forwarding
head only displays the first few lines
tail only displays the next few lines
n displays the file content with line numbers
od displays the file content in binary mode

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326803402&siteId=291194637