Linux Tail command use method detailed

Source: Internet
Author: User

First, tail command syntax
tail [f] [-c number |-N number |-M number |-B number |-K number] [File]

Parameter description:

-F This parameter is used to monitor file growth.
-c number reads the specified file from the number byte position
-N number reads the specified file from the number row position.
-m number reads the specified file from the byte character position, such as if your file contains Chinese text, if you specify the-c parameter, it may cause 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 file name of the operation
In the above command, number is involved, and if unspecified, 10 rows are displayed by default. Number is preceded by an indication of whether the offset is calculated from the top or the tail.

The tail executable file is typically under/usr/bin/.

Example

To display the last ten lines of the notes file, enter:
Tail notes to specify the number of rows to begin reading from the end of the Notes file, enter:
Tail-n notes
To start with the No. 200 byte, display a one-page notes file at a time, enter:
Tail-c +200 Notes | Pg
To track the growth of a file, enter:
Tail-f accounts
This displays the last ten lines of the accounts file. The tail command continues to display the rows added to the accounts file. Explicitly

The example continues until you press the CTRL-C key sequence to stop.
The file/usr/bin/tail contains the tail command.


Description: The last 10 lines of filename are displayed in reverse order.

Add:

Similar to the tail function of the command and "FRM: Brother Bird":

Cat Displays the contents of the file starting with the first line.
The TAC starts displaying the contents of the archive from the last line.
More paging displays the contents of the file.
Less is similar to more but supports paging forward
Head shows only the previous lines
Tail only shows the following lines
N with line number display file contents
OD displays file contents in binary mode

--retry
still tries to open a file even if it cannot be accessed at the start of the tail or after tail is run.--only useful when sharing with-F.
-C,--bytes=n
outputs the last N bytes
-F,--follow[={name|descriptor}]
When the file grows, the output is subsequently added;-F,--follow, and--follow=desc Riptor are all the same meaning
-n,--lines=n
outputs the last n rows instead of the default last 10 lines
--max-unchanged-stats=n
See the Texinfo document (default is 5)
--max-co Nsecutive-size-changes=n
See Texinfo document (default)
--pid=pid
is shared with-F to end after the process id,pid dead.
-Q,--quiet,--silent
never outputs the first
-S,--sleep-interval=s
of the filename to be shared with-F, which means that each recurring interval sleeps with s sec
-V,--verbose
Always output the first
--help
that gives the file name after you exit the
--version
Output version information and exit
if n (byte or number of lines) is ' + ', then the nth item from the beginning of each file is displayed, no , the last N entry for the file is displayed. n can have a multiple prefix: b means that 512,k says 1024,m 1048576 (1 trillion). The first option-value or +value is treated as-n-Value or-n +value, unless VALUE contains one of the [bkm] suffix multiples, in which case it is treated as C-value or-C-+value

When the

uses--follow (-f), tail defaults to the file descriptor, which means that tail can trace to the end of the file even if tail is renamed. If you do want to query the actual name of the file rather than the file descriptor (for example, log rotation), This default action is not what you expect. In this case the--follow=name should be used. This will cause tail to track whether it was deleted or recreated by another program by periodically reopening the specified file.

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.