Force a shell script to fflush

后端 未结 3 1793
深忆病人
深忆病人 2020-12-17 18:08

I was wondering if it was possible to tell bash that all calls to echo or printf should be followed up by a subsequent call to fflush()

3条回答
  •  情深已故
    2020-12-17 19:01

    If you force the file to be read, it seems to cause the buffer to flush. These work for me.

    Either read the data into a useless variable:

        x=$(<$logfile)
    

    Or do a UUOC:

        cat $logfile > /dev/null
    

提交回复
热议问题