One day a linux base command view file at the beginning of the end part of the content tail

Source: Internet
Author: User

Tail Show end of file

1 , command format

Tail[option] ... [File] ...

2 , command functions

show file contents, display the file's 10 lines by default, you can use [-n] # | [-#] # represents the number of rows displayed, options specify how many rows to display

use tail command -f option for easy access to changing log files , tail -f filename filename , refresh display

3 , common options

- C # : Displays the bytes of the file ( character ) number

- N # : Shows how many lines of a file

- F : Cyclic display, when the content of the file changes, display the changed content, do not exit, wait for the next change

--pid=pid : With - F when the process ID die, PID dead process is over .

- s,--sleep-interval=n:Sleep (Hibernate), with- Fshared, when dormant.Nseconds before reading the contents of the specified file, each time reading hibernationNseconds

4 , command instance

1. View the contents of the file after N rows

[[Email protected]~]# cat Test 1 Askdasjkdhsak 2 hkjasd 3 hakjsd 4 HJAKSD 5 HAKSDLASDA S 6 kasdl[[email protected] ~] #tail-N 3 test hjaksdhaksdlasdaskasdl[[email protected]~]# tail-3 test hjaksdhaksdl Asdaskasdl[[email protected]~]#


2. cycle through the contents of a file

command: tail-f Ping.log

[[Email protected]~]# ping 172.16.2.2 >ping.log &[[email protected]~]# tail-f ping.log PING172.16.2.2 (172.16.2.2 ) bytes of data.64 bytesfrom 172.16.2.2:icmp_seq=1 ttl=64 time=0.028 ms64 bytesfrom 172.16.2.2:icmp_seq=2 ttl=64  time=0.034 ms64 bytes from172.16.2.2:icmp_seq=3 ttl=64 time=0.028 ms64 bytesfrom 172.16.2.2:icmp_seq=4 ttl=64 time=0.029 Ms64 bytesfrom 172.16.2.2:icmp_seq=5 ttl=64 time=0.028 ms ... [[Email protected]~]#


tip: ping 172.16.2.2 > ping.log & // in the background ping remote host. and output the file to ping.log ctrl + c to terminate.

3. start displaying files from Nth line

command: tail-n +# File

[[Email protected]~] #tail-n +3 test Askdasjkdhsakhkjasdhakjsd[[email protected]~]



This article is from "Linux rookie" blog, please be sure to keep this source http://geekb0y.blog.51cto.com/10743719/1883869

One day a linux base command view file at the beginning of the end of the content tail

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.