Linux經常使用命令之tail

tail

NAME

tail - output the last part of files

SYNOPSIS

tail [OPTION]... [FILE]...

DESCRIPTION

  • Print the last 10 lines of each FILE to standard output. With morethan one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input.Mandatory arguments to long options are mandatory for short options too.
  • 輸入文件中的尾部內容。tail命令默認在屏幕上顯示指定文件的末尾10行。若是給定的文件不止一個,則在顯示的每一個文件前面加一個文件名標題。若是沒有指定文件或者文件名爲「-」,則讀取標準輸入。

-c, --bytes=[+]NUM

  • output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file
  • 輸出文件尾部的N(N爲整數)個字節內容

-f, --follow[={name|descriptor}]

  • output appended data as the file grows;an absent option argument means 'descriptor'
  • 顯示文件最新追加的內容。「name」表示以文件名的方式監視文件的變化。「-f」與「-fdescriptor」等效

-F

  • same as --follow=name --retry

-n, --lines=[+]NUM

  • output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM
  • 輸出文件的尾部N(N位數字)行內容

--max-unchanged-stats=N

  • with --follow=name, reopen a FILE which has not changed size after N (default 5) iterations to see if it has

been unlinked or renamed (this is the usual case of rotated log files); with inotify, this option is rarely usefullinux

--pid=PID

  • with -f, terminate after process ID, PID dies

-q, --quiet, --silent

  • never output headers giving file names

--retry

  • keep trying to open a file if it is inaccessible
  • 便是在tail命令啓動時,文件不可訪問或者文件稍後變得不可訪問,都始終嘗試打開文件。使用此選項時須要與選項「——follow=name」連用

-s, --sleep-interval=N

  • with -f, sleep for approximately N seconds (default 1.0) between iterations; with inotify and --pid=P, check process P at least once every N seconds
  • 與「-f」選項連用,指定監視文件變化時間隔的秒數

-v, --verbose

  • always output headers giving file names
  • 當有多個文件參數時,老是輸出各個文件名

-z, --zero-terminated

  • line delimiter is NUL, not newline

--help

  • display this help and exit

--version

  • output version information and exit
  • NUM may have a multiplier suffix: b 512, kB 1000, K 1024, MB 10001000, M 10241024,

GB 100010001000, G 102410241024, and so on for T, P, E, Z, Y.app

  • With --follow (-f), tail defaults to following the file descriptor,which means that even if a tail'ed file is renamed, tail will continue to track its end. This default behavior is not desirable when you really want to track the actual name of the file, not thefile descriptor (e.g., log rotation). Use --follow=name in thatcase.That causes tail to track the named file in a way that accommodates renaming, removal and creation.

See

All rights reserved

相關文章
相關標籤/搜索