How to use Linux tail commands

Source: Internet
Author: User

This article describes how to use the Linux Tail command. The use of the Linux Tail command is to output the last part of the specified file to a standard device, usually a terminal, in layman's terms, to display the last few lines of an archive file to the terminal, assuming that the file is updated and tail will refresh itself to ensure that you see the latest file content.

First, 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 file growth. -c number reads the specified file from the number byte position-n number from the number line position of the specified file. -m number reads the specified file from the multiple-byte character position, for example, if your file assumes that you include Chinese characters, it is assumed that specifying the-c parameter may result in truncation, but using-m avoids the 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 name of the operation. The above command, which involves number, assumes that 10 rows are displayed by default, if not specified. Number is preceded by a sign that indicates whether the offset is calculated from the top or from the tail. Tail can run files are generally below/usr/bin/.

Second, tail command use method demonstration example

1, tail-f filename Description: Monitor the tail of the filename file (the default 10 lines, equivalent to increase the parameter-n 10), refresh display on the screen. Exit, press CTRL + C.

2. Tail-n FileName Description: Displays the last 20 lines of the filename.

3. TAIL-R-N FileName Description: Reverse shows the last 10 lines of filename.

Add: Commands similar to the tail feature are: Cat starts displaying the contents of the archive from the first line. The TAC starts by displaying the contents of the archive from the last line. More paging displays the contents of the archive. Less is similar to more, but supports the front page head just shows the first few lines tail only shows the next few rows n with the line number showing the contents of the archive OD binary display of the contents of the file

How to use Linux tail commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.