当前位置:首页 > linux > 正文

linux中tail怎么用(linux终端如何设置)

  • linux
  • 2024-03-15 19:27:07
  • 7981
Linux 中 tail 命令
功能: 显示文件的最后几行
语法:
tail [选项] [文件]
要素:
-f(--follow): 在文件被修改时持续显示新行。
-n(--lines): 指定显示文件的最后 n 行(默认 10 行)。
-c(--bytes): 指定显示文件的最后 c 个字节。
-q(--quiet): 不显示文件名。
-s(--sleep-interval): 在 -f 模式下,指定在检查文件是否有新内容之间的休眠时间(以秒为单位)。
示例:
显示文件 hello.txt 的最后 5 行:
tail -n 5 hello.txt
持续显示文件 hello.txt 的新行:
tail -f hello.txt
显示文件 hello.txt 的最后 1000 个字节:
tail -c 1000 hello.txt
不显示文件名,持续显示文件 hello.txt 的新行:
tail -fq hello.txt
以每 10 秒检查新内容的方式持续显示文件 hello.txt 的新行:
tail -fs 10 hello.txt