Redirecting sorted output back onto the input file truncates it before sort finishes reading, destroying data. sponge from moreutils soaks up all input first and writes the file only after the command completes. This makes in-place transforms like sort sp.txt | sponge sp.txt safe. The same pattern works for any file-modifying pipeline.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.