0

I can do

tail -vf -c5 thefile    \
    | cat -n            \   
    | sed -E 's/a/b/g'  \
    ;

But the following gives no output.

tail -vf -c5 thefile    \
    | cat -n            \   
    | sed -E 's/a/b/g'  \
    | sed -E 's/f/F/g'  \
    ;

Why?

john-jones
  • 1,736

1 Answers1

1

sed is buffering its output. Use the -u option (if present, e.g. GNU sed) to flush the buffers more aggressively.

You can also use the stdbuf tool which modifies the buffering behaviour:

tail -vf -c5  thefile | cat -n | stdbuf -oL sed -E 's/a/b/g' | sed -E 's/f/F/g'
choroba
  • 47,233