每天回顾linux命令(tail)

来源:互联网 发布:c语言char什么意思 编辑:程序博客网 时间:2024/06/04 23:20

tail命令
tail命令用于输出文件中尾部内容。tail命令默认在屏幕上显示指定文件的末尾10行。如果给定的文件不止一个,则在每个文件前面加一个文件名标题。如果没有指定文件或者文件名为”-“,则读取标准输入。
注意:如果表示字节或者行数的N前面加一个”+”号,则从文件开头的第N项开始显示,而不是显示文件的最后N项,N值后面可以用有党委后缀。b表示512,k表示1024,m表示1兆。

语法

tail (选项) (参数)

选项
-c + number或者–byte+ number:输出文件尾部number(number为整数)字节的内容,number可以带单位

root@68fc0a9bc6dd:/home/wzm/testtail# tail -c 100 redis.confve-defrag-cycle-min 25# Maximal effort for defrag in CPU percentage# active-defrag-cycle-max 75

-f < name/descriptor >或–follow < namedescript>:显示文件最新追加的内容,“name”表示以文件名的方式检视文件的变化。

root@68fc0a9bc6dd:/home/wzm/testtail# tail -f redis.conf# Maximum percentage of fragmentation at which we use maximum effort# active-defrag-threshold-upper 100# Minimal effort for defrag in CPU percentage# active-defrag-cycle-min 25# Maximal effort for defrag in CPU percentage# active-defrag-cycle-max 75

可以看出加上-f后为阻塞状态
**-F:和选项-f加上–retry功能相同。
-n或–line + number:输出文件尾部number行内容。**

root@68fc0a9bc6dd:/home/wzm/testtail# tail -n 2 redis.conf# active-defrag-cycle-max 75

–pid=<进程号>:和-f连用,当指定的进程号的进程终止后,自动退出tail命令
-q或者–quiet或–silent:有多个文件参数时,不输出各个文件名。

root@68fc0a9bc6dd:/home/wzm/testtail# tail -q README.md  redis.confThere are tons of commands implementations inside th Redis source codethat can serve as examples of actual commands implementations. To writea few toy commands can be a good exercise to familiarize with the code base.There are also many other files not described here, but it is useless tocover everything. We want to just help you with the first steps.Eventually you'll find your way inside the Redis code base :-)Enjoy!# Maximum percentage of fragmentation at which we use maximum effort# active-defrag-threshold-upper 100# Minimal effort for defrag in CPU percentage# active-defrag-cycle-min 25# Maximal effort for defrag in CPU percentage# active-defrag-cycle-max 75root@68fc0a9bc6dd:/home/wzm/testtail#

-s + 秒数 或 –sleep-interal=秒数 :和-f选项连用,指定减少文件变化时间间隔的秒数。
-v或–verbose:当有多个文件参数时,总是输出各个文件名。默认会带上

root@68fc0a9bc6dd:/home/wzm/testtail# tail -v README.md  redis.conf==> README.md <==There are tons of commands implementations inside th Redis source codethat can serve as examples of actual commands implementations. To writea few toy commands can be a good exercise to familiarize with the code base.There are also many other files not described here, but it is useless tocover everything. We want to just help you with the first steps.Eventually you'll find your way inside the Redis code base :-)Enjoy!==> redis.conf <==# Maximum percentage of fragmentation at which we use maximum effort# active-defrag-threshold-upper 100# Minimal effort for defrag in CPU percentage# active-defrag-cycle-min 25# Maximal effort for defrag in CPU percentage# active-defrag-cycle-max 75

参数:
文件列表:指定要显示尾部内容的文件列表

原创粉丝点击