Verdi, On Tuesday 30 August 2005 22:26, Verdi March wrote:
Hi,
when I redirect the output of a program to a file, e.g. myprog > file.txt, the shell seems to buffer the output before writing to the file. From my observation on my machine, the buffer seems to be 4K.
Is there a way to let bash immediately write any output strings to file (not using buffer at all)? TIA.
BASH is not involved in buffering the output of processes it spawns (*). The program itself (its use of standard I/O libraries and / or system calls, etc.) determines whether or how much buffering is performed or when the output buffer is flushed. It cannot be controlled from the shell, BASH or otherwise. The classic C stdio library, e.g., alters its buffering behavior based on the kind of output destination, mostly whether it's a tty or some other kind of file. (*) The only exception is for commands that are built into the shell itself (there are many).
-- Regards, Verdi
Randall Schulz