Am I blind or is there no option like --in-place for sort?In order to save results to the input file, sed uses -i (--in-place).Redirecting the output of sort to the input filesort < f > fresults in making it empty. If there is no --in-place option - maybe there is some trick how to do this in handy way?(The only thing that cames to my mind: sort < f > /tmp/f$$ ; cat /tmp/f$$ > f ; rm /tmp/f$$Moving is not right choice, cause file permissions might be changed. That's why I overwrite with the contents of the temp file which I then remove.)
Does sort support sorting a file in-place, like `sed --in-place`?
text processing;sort
sort has the -o, --output option that takes a filename as argument. If it is the same as the input file, it writes the result to a temporary file, then overwrites the original input file (exactly the same thing as what sed -i does).From GNU sort info page:`-o OUTPUT-FILE'`--output=OUTPUT-FILE'      Write output to OUTPUT-FILE instead of standard output.  Normally,      `sort' reads all input before opening OUTPUT-FILE, so you can      safely sort a file in place by using commands like `sort -o F F'      and `cat F | sort -o F'.  However, `sort' with `--merge' (`-m')      can open the output file before reading all input, so a command      like `cat F | sort -m -o F - G' is not safe as `sort' might start      writing `F' before `cat' is done reading it.      On newer systems, `-o' cannot appear after an input file if      `POSIXLY_CORRECT' is set, e.g., `sort F -o F'.  Portable scripts      should specify `-o OUTPUT-FILE' before any input files.and from The Open Group Base Specifications Issue 7:-o  output    Specify the name of an output file to be used instead of the standard     output. This file can be the same as one of the input files.