Linux shell-tail

使用tail --help查看命令用于备忘

tail [  -f ] [  -c Number |  -n Number |  -m Number |  -b Number |  -k Number ] [ File ]

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; or use -c +K to output
bytes starting with the Kth of each file
-f, --follow[={name|descriptor}]
output appended data as the file grows;
an absent option argument means ‘descriptor‘

(PS:参数-f使tail不停地去读最新的内容;e.g:tail -f -n 500监控显示500尾行内容)
-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 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 if it is inaccessible
-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.

时间: 2024-08-25 10:21:13

Linux shell-tail的相关文章

Linux shell脚本-基础学习笔记

Linux脚本能力不是太强,最近再补习下,毕竟linux shell在日常工作中还是很普遍的, 用起来更方便.省时省力. 以下是学习笔记,偏理论,后面有几个例子,供参考. shell脚本组成元素系统命令.文本处理工具(grep\sed等).变量.条件判断.循环结构和函数 -------------------------------------------- 三剑客:grep,sed,awk,还有wc,sort,head等 ------------------------------------

Linux shell脚本基础学习详细介绍(完整版)一

Linux shell脚本基础学习这里我们先来第一讲,介绍shell的语法基础,开头.注释.变量和 环境变量,向大家做一个基础的介绍,虽然不涉及具体东西,但是打好基础是以后学习轻松地前提.1. Linux 脚本编写基础◆1.1 语法基本介绍 1.1.1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序.在这个例子中我们使用/bin/sh来执行程序. 当编辑好脚本时,如果要执行该脚本,还必须使其可执行. 要使脚本可执

37条常用Linux Shell命令组合

序号 任务 命令组合 1 删除0字节文件 find . -type f -size 0 -exec rm -rf {} \; find . type f -size 0 -delete 2 查看进程,按内存从大到小排列 ps -e -o “%C : %p : %z : %a”|sort -k5 -nr 3 按cpu利用率从大到小排列 ps -e -o “%C : %p : %z : %a”|sort -nr 4 打印说cache里的URL grep -r -a jpg /data/cache/*

常用Linux Shell命令组合

序号 任务 命令组合 1 删除0字节文件 find . -type f -size 0 -exec rm -rf {} \;find . type f -size 0 -delete 2 查看进程,按内存从大到小排列 ps -e -o “%C : %p : %z : %a”|sort -k5 -nr 3 按cpu利用率从大到小排列 ps -e -o “%C : %p : %z : %a”|sort -nr 4 打印说cache里的URL grep -r -a jpg /data/cache/*

Linux shell 指令

Linux shell指令运行的原理: Linux严格意义上说的是一个操作系统,我们称之为"核心(kernel)" ,但我们一般用户,不能直接使用kernel.而是通过 kernel的"外壳"程序,也就是所谓的shell,来与kernel沟通.shell对于Linux,有相同的作用,主要是对我们的指令进行解析,解析指令给Linux内核.反馈结果在通过内核运行出结果,通过shell解析给用户. ls指令 -a 列出目录下的所有文件,包括以.开头的隐含文件. cd命令

LINUX SHELL脚本攻略笔记[速查]

Linux Shell脚本攻略笔记[速查] 资源 shell script run shell script echo printf 环境变量和变量 pgrep shell数学运算 命令状态 文件描述符和重定向 cat 数组和关联数组 alias date 调试脚本 函数和参数 管道 读取命令输出 read 字段分隔符和迭代器 循环 比较和测试 find xargs tr md5sum sha1sum 对目录进行校验 sort uniq tempfile split bash变量匹配切分 exp

linux shell 命令

linux shell 命令 什么是Shell? Shell 是连接操作系统内核 与 用户 的接口. 终端是shell的表现形式. 什么是Shell编程? Shell 脚本语言加上linux 命令语句就构成了shell程序.优点在于批量处理.不用用户每次手动输入. bash是shell程序解释器的一种. 常用命令 pwd:print working directory,打印工作目录. cd:chang directory,改变工作目录. 可使用绝对命令或相对命令. ls:list,查看目录内容.

Requirement-Driven Linux Shell Programming

*/--> Requirement-Driven Linux Shell Programming Table of Contents 1. Where can I find the basic Material about Linux Shell Programming? 2. How to time a function/program(Get the execution time of a program)? 3. How to pass parameters to a function?

Linux Shell 文本处理工具集锦 zz

内容目录: find 文件查找 grep 文本搜索 xargs 命令行参数转换 sort 排序 uniq 消除重复行 用tr进行转换 cut 按列切分文本 paste 按列拼接文本 wc 统计行和字符的工具 sed 文本替换利器 awk 数据流处理工具 迭代文件中的行.单词和字符 本文将介绍Linux下使用Shell处理文本时最常用的工具: find.grep.xargs.sort.uniq.tr.cut.paste.wc.sed.awk: 提供的例子和参数都是最常用和最为实用的: 我对shel

Linux Shell常用技巧(十) 管道组合

Linux Shell常用技巧(十) 管道组合 二十. 通过管道组合Shell命令获取系统运行数据:  1.  输出当前系统中占用内存最多的5条命令:    #1) 通过ps命令列出当前主机正在运行的所有进程.    #2) 按照第五个字段基于数值的形式进行正常排序(由小到大).    #3) 仅显示最后5条输出.    /> ps aux | sort -k 5n | tail -5    stephen   1861  0.2  2.0  96972 21596  ?  S     Nov1