Bash: standard output puzzle
-
04-03-2021 - |
質問
When one does
process > file
Standard output gets written to a file only once the process is over. Is there a way to write it right away?
Namely, I'm doing batch conversion odt2pdf with:
libreoffice --convert-to pdf:writer_pdf_Export *.odt
So libreoffice says about which files are processed right away. But when I do:
libreoffice --convert-to pdf:writer_pdf_Export *.odt > log
The information is written only once I close libreoffice. (I want to read the number of lines in the log - and this way I'll kill libreoffice when all files are processed)
Edit:
I found a command line option of libreoffice which I misunderstood at first: --invisible
- so it will kill itself after what it has to do - so I don't need to kill it myself - hence no problem any more.
解決
try
unbuffer libreoffice --convert-to pdf:writer_pdf_Export *.odt > log
Note to general readers, unbuffer
is not always available as a std binary in old-style Unix platforms and may require a search and installation for a package to support it.
Also note that O.P. @Adobe found that libreoffice
has an --invisible
option that solved the issue, i.e.
libreoffice --invisible --convert-to pdf:writer_pdf_Export *.odt > log
I hope this helps.