How to write to a file and, while the file is still being writen, read and parse its contents using
Posted
by Isabelle
on Server Fault
See other posts from Server Fault
or by Isabelle
Published on 2010-03-17T10:48:14Z
Indexed on
2010/03/17
10:51 UTC
Read the original article
Hit count: 257
Hello.
I'm actually trying to write a shell script that logs the output of a command to a file but, since the command takes a long time to complete (about 15 minutes), I would like to start parsing the output of the command (content of the file) before the command is completed, so I can send messages to the standard output (the user), like:
10% complete
45% complete
and so on.
Program steps
- Redirect command to a file: $(command) > $FILE
- Start reading and parsing the output ($FILE) before the command is finished.
I thought of using pararell programming, but I havent't got the hang of it.
Any help you be appreciated.
Best regards.
© Server Fault or respective owner