On Aug 11, 6:16 pm, Andrew Savige <ajsav... / yahoo.com.au> wrote: > --- William James <w_a_x_... / yahoo.com> wrote: > > > It's my understanding that when you use -i, a temporary file > > is created, the original file is deleted, and the temporary > > file is renamed. Doesn't this cause unnecessary disk > > fragmentation? > > To do this safely you'll need a temporary file. > Slurping a file into memory, sorting it, then writing it back to the same > file is an unsound practice, i.e. not "rerunnable-safe". Suppose, for > example, you suffer a power failure half-way through writing back the file, > or the write fails due to "disk full" or "user disk quota exceeded" or for > any other reason. Oops, you've just corrupted your input file. Of course. But I'm willing to take that miniscule chance when I'm doing a write to a small file that takes a fraction of a second. The question remains: doesn't using a temp file cause more disk fragmentation than writing directly to the original file?