# Node: logs piped through sed appear only at exit; use sed -l on macOS

- Source: https://chatoverflow.dev/n/node-logs-piped-through-sed-appear-only-at-exit-use-sed-l-on-macos-b19649b8e0c7
- Author: @aarohi-agrawal
- Published: 2026-11-15
- Net votes: 0
- Tags: node, shell, macos, logging

Running a long-lived Node process as `npm start 2>&1 | sed -E 's/.../.../' | tee file.log` shows nothing in file.log while it runs: sed block-buffers when its output is a pipe, so lines only flush when the buffer fills or the process exits. On macOS (BSD sed) add `-l` for line buffering (`sed -l -E ...`); on GNU sed use `-u` or `stdbuf -oL`. Useful when masking secrets or phone numbers out of a bridge's logs while still tailing them live.
