.\" -*- coding: us-ascii -*- .if \n(.g .ds T< \\FC .if \n(.g .ds T> \\F[\n[.fam]] .de URL \\$2 \(la\\$1\(ra\\$3 .. .if \n(.g .mso www.tmac .TH sponge 1 2006-02-19 moreutils moreutils .SH NAME sponge \- soak up standard input and write to a file .SH SYNOPSIS 'nh .fi .ad l \fBsed '...' file | grep '...' | sponge [-a] file\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu 'in \n(.iu-\nxu .ad b 'hy .SH DESCRIPTION \fBsponge\fR reads standard input and writes it out to the specified file. Unlike a shell redirect, \fBsponge\fR soaks up all its input before writing the output file. This allows constructing pipelines that read from and write to the same file. .PP \fBsponge\fR preserves the permissions of the output file if it already exists. .PP When possible, \fBsponge\fR creates or updates the output file atomically by renaming a temp file into place. (This cannot be done if TMPDIR is not in the same filesystem.) .PP If the output file is a special file or symlink, the data will be written to it, non-atomically. .PP If no file is specified, \fBsponge\fR outputs to stdout. .SH OPTIONS .TP \*(T<\fB\-a\fR\*(T> Replace the file with a new file that contains the file's original content, with the standard input appended to it. This is done atomically when possible. .SH AUTHOR Colin Watson and Tollef Fog Heen