sponge

Go implementation of moreutils's sponge(1) command.
Usage
$ sponge --help
Usage: sponge [-ar] [[-o] FILE]
sponge [-ar] [[-o] FILE] -- COMMAND [ARGS...]
sponge reads the standard input and writes it to the specified file.
Unlike shell redirects, sponge reads all input before writing output.
This allows to build a pipeline that reads from and writes to the same file.
If FILE is omitted, sponge will write to the standard output.
If COMMAND is specified, the command is executed, and only if it terminates
successfully, its output is written to FILE.
Options:
-a, --append Append to FILE instead of overwriting it
-r, --replace Replace FILE atomically instead of overwriting it
-o, --output=FILE Write output to FILE
-h, --help Show this help message and exit
--version Show version information and exit
Installation
Download from GitHub Releases
Build from source
$ go install github.com/cions/sponge/cmd/sponge@latest
License
MIT