Line Buffering

So I had this problem where I 'tail'-ed a file, and 'awk'-ed the results, and that worked fine.

After that I wanted to further 'sed' the outcome of the 'awk', and there's where things went wrong, i.e. no output.

So after a decent search I found that 'awk' buffers the output, and I had to 'unbuffer' that. Some 'awk's seem to have an option to switch that on or off, but not on FreeBSD (at least, I didn't find it). So I found something cool:

stdbuf -oL

Put this in front of the buffering command unbuffers the output, and then things start working again:

tail -f /some/file | stdbuf -oL awk '$4 == "something" {printf "%s %s\n", $3, $8}' | sed 's/.*\([0-9]\{1,5\}\) \(.*\)/\1 \2/'

\me happy


Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.