对 tail -f 使用管道

Frytea 2026-06-03 09:03:24 累计浏览 371 次

来源: 对 tail -f 使用管道

最近发现 tail -f 时管道后面的程序都会被卡住,才发现 grep,sed,awk 不直接输出到 TTY 时都是带缓冲的。平时跟在 cat 后使用没问题是因为输入管道关闭触发了 flush。本文详细解释其中的坑,以及怎么让 sed, awk, grep 立即 flush。

同分类推荐文章

  1. NGINX Gateway Fabric 2.8: IP allow and deny lists, passive health checks, and cookie-based session persistence (2026-11-14 01:10:02)
  2. NGINX Ingress Controller 5.7: HTTP/2 to your upstreams, Opaque Secrets, and cert-manager challenges behind HTTPS redirects (2026-11-14 00:10:02)
  3. Hexo 文章一键发布到微信公众号 (2026-11-13 19:10:02)

查看更多 DevOps 文章 →

建议继续学习

  1. 28个Unix/Linux的命令行神器 (累计阅读 17,183)
  2. 利用find和sed批量替换文件内容 (累计阅读 11,744)
  3. Linux grep命令用法 (累计阅读 7,309)
  4. linux下的高效代码搜索工具-ack (累计阅读 6,973)
  5. grep 正则表达式选项要记得转义 (累计阅读 6,847)
  6. 学习Grep,Sed中的正则 (累计阅读 5,651)
  7. tailf and tail -f (累计阅读 5,243)
  8. SED命令行脚本快速参考,AWK命令行脚本快速参考,perl命令行脚本快速参考 (累计阅读 5,093)
  9. 记一下我的ubuntu升级到10.04时遇到都问题 (累计阅读 5,096)
  10. sed命令使用 (累计阅读 4,669)