tail命令行参数

来源:互联网 发布:淘宝助理下载不了订单 编辑:程序博客网 时间:2024/05/19 23:18
DESCRIPTION )在标准输出上显示每个FILE的最后10行.
如果多于一个FILE,会一个接一个地显示, 并在每个文件显示的首部给出文件名.
如果没有FILE,或者FILE是-,那么就从标准输入上读取.

--retry
即使tail开始时就不能访问
或者在tail运行后不能访问,也仍然不停地尝试打开文件. --
只与-f合用时有用.

-c, --bytes=N
输出最后N个字节

-f, --follow[={name|descriptor}]
当文件增长时,输出后续添加的数据; -f, --follow以及 --fol-
low=descriptor 都是相同的意思

-n, --lines=N
输出最后N行,而非默认的最后10行

--max-unchanged-stats=N
参看texinfo文档(默认为5)

--max-consecutive-size-changes=N
参看texinfo文档(默认为200)

--pid=PID
与-f合用,表示在进程ID,PID死掉之后结束.

-q, --quiet, --silent
从不输出给出文件名的首部

-s, --sleep-interval=S
与-f合用,表示在每次反复的间隔休眠S秒

-v, --verbose
总是输出给出文件名的首部

--help 显示帮助信息后退出

--version
输出版本信息后退出

如果N(字节或者行数)的第一个字符为`+',
那么从每个文件的开头算起的第N项开始显示, 否则, 显示该文件的最后N项.
N可以有一个倍数前缀: b表示512,k表示1024,m表示1048576(1兆). 第一个选项
-VALUE 或+VALUE 以-n VALUE或-n +VALUE
方式看待,除非VALUE含有[bkm]后缀倍数 中的一个,在这种情况下,它被看作 -c
VALUE 或者-c +VALUE

使用--follow (-f)时,tail默认后接文件描述符,
这意味着即使tail显示的文件改名了,tail仍然可以 追踪到其末尾部分.
如果你确实希望查询文件的实际名而非文件描述符 (例如,日志轮转时),
这种默认的操作就不是你所期望的了. 在这种情况下应使用--follow=name.
这将导致tail通过周期性地重新打开所指定的文件来

追踪其是否被删除了,或者被其他程序重新创建了.


#tail --help

Usage: tail [OPTION]... [FILE]...
Print the last 10 lines of each FILE to standard output.
With more than 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.
  -c, --bytes=K            output the last K bytes; alternatively, use -c +K
                           to output bytes starting with the Kth of each file
  -f, --follow[={name|descriptor}]
                           output appended data as the file grows;
                           -f, --follow, and --follow=descriptor are
                           equivalent
  -F                       same as --follow=name --retry
  -n, --lines=K            output the last K lines, instead of the last 10;
                           or use -n +K to output lines starting with the Kth
      --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 useful.
      --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 even when it is or
                             becomes inaccessible; useful when following by
                             name, i.e., with --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.
  -v, --verbose            always output headers giving file names
      --help     display this help and exit
      --version  output version information and exit

If the first character of K (the number of bytes or lines) is a `+',
print beginning with the Kth item from the start of each file, otherwise,
print the last K items in the file.  K may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

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 the file descriptor (e.g., log
rotation).  Use --follow=name in that case.  That causes tail to track the
named file in a way that accommodates renaming, removal and creation.

Report tail bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'tail invocation'

原创粉丝点击