antee - read input from STDIN, write to a temporary staging file, and rename it to FILENAME when there is nothing left to read.
antee [-t|--stdout] [-T|--stderr] [-n|--no-clobber] FILENAME
antee is like tee(1) in that it reads input from STDIN and writes it to a file, but all output is staged to the temporary file first, which is renamed to the final filename only when there is nothing left to read. It is useful for staging the output of long running processes with lots of output, to avoid partially written files in the case of error.
-t write all input to stdout -T write all input to stderr -n do not clobber if FILENAME already exists
The name 'antee' was chosen b/c 'antechamber' means waiting room, so it's tee(1) with a waiting room...
Write all the output of long_running_process to output-file.tmpXXXXX, where XXXXX are random characters, and rename output-file.tmpXXXXX to output-file only when long_running_process is finished:
long_running_process | antee output-file
You don't have to check the output-file to see if it completed or not, since it'll never be created if it didn't. In case of error, just remove the tmp files with the command below and start over:
Write all output of long_running_process to output-file via a temporary file like above, but pipe all output to some_other_program as well.
long_running_process | antee -t output-file | some_other_program
Same as above, but without the benefit of a temporary file by using the tee command instead of antee.
long_running_process | tee output-file | some_other_program
T. Nishimura <firstname.lastname@example.org>
This software is copyright (c) 2013 by T. Nishimura.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.