Skip to main content
2 of 4
improved formatting

Use sponge from the moreutils package. It has the advantage that it does not write to stdout.

    echo test | sudo sponge /tmp/foo

Use the -a option to append to a file instead of overwriting it.