1

Write file instantly (without line buffering) in shell script

view story
linux-howto

http://stackoverflow.com – I have a script like this, #!/bin/bash echo "hello" > a.txt while [ True ]; do #do something here, very long and possiblely causing system reboot done It looks like I can only get a normal a.txt (with "hello" inside) if the execution is ended normally. In the case that the "while loop" is running or a system reboot was triggered during the while loop, there will be a blank a.txt. By Google searching, it seemed to be a line-bufferring issue as shell turns on line bufferring by default. As there is no "Expect" or "stdbuf" installed on my customized Ubuntu, I tried to replace echo "he (HowTos)