Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When using the GNU coreutils split command with verbose mode, how can I make the lines that appear in the STDOUT be flushed with respect to the time when the file has finally been created?

Fore example, running it like this:

~/coreutils/bin/split --verbose -d -u -l 10000000 1>out & tail -f out
creating file `x00'
creating file `x01'
creating file `x02'

I would have expected the line creating file 'x00' to have appeared in file out after the file has been completely written, but instead, it seems like nothing is written into out until the whole file has been finally processed. Is there a way to change this behavior?

share|improve this question
I think all GNU coreutils use output buffering, so they won't output anything until the buffer is filled or earlier if the output is an interactive terminal. – MV. Jul 2 '12 at 14:53
output to stdout is buffered, stderr is not. – lornix Jul 2 '12 at 17:19
up vote 1 down vote accepted

Ok, old versions of GNU coreutils (before 7.5) don't have an easy workaround (as far as I know), but newer versions (since 7.5) have a stdbuf command you can use to force split (or any other coreutil program) to immediately print its output. In your case, you can use:

~/coreutils/bin/stdbuf -o0 ~/coreutils/bin/split --verbose -d -u -l 10000000 1>out & tail -f out

That will run split with output buffering disabled.

Please note the -u option (unbuffered) in split does not affect the message printing, only the data it's splitting (it feels slower if you disable that buffering).

Information about stdbuf:

For an alternative when using older coreutils versions, check this solution using command unbuffer from the package expect (tcl):

share|improve this answer
Brilliant! Thanks! – 719016 Jul 2 '12 at 18:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.