English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Commande tail de Linux

大全命令 Linux

La commande tail peut être utilisée pour afficher le contenu des fichiers, avec un paramètre couramment utilisé -f est souvent utilisé pour consulter les fichiers journaux en cours de modification.

tail -f filename 会把 filename 文件里的最尾部的内容显示在屏幕上,并且不断刷新,只要 filename 更新就可以看到最新的文件内容。

格式命令:

命令 tail [参数] [文件]

参数:

  • -循环读取

  • -信息处理不显示

  • -详细信息处理显示

  • -字节数<数目> 显示的字节数

  • -行数<数目> 显示文件的尾部 n 行内容

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

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

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

示例

要显示 notes.log 文件的内容,请输入以下命令: 10 行,请输入以下命令:

notes.log tail

要跟踪名为 notes.log 的文件的增长情况,请输入以下命令:

tail -f notes.log

此命令显示 notes.log 文件的最后 10 行。当将某些行添加至文件 notes.log 时,命令 tail 会继续显示这些行。显示一直继续,直到您按下(Ctrl-键组合(C)停止显示。

内容显示文件 notes.log,从第 2行至文件末尾 0

tail -n +2notes.log 0

显示最后文件 notes.log 10 字符个:

tail -c 10 notes.log

大全命令 Linux