The '-o' option was already in the the sort
of the Sixth Edition of Unix
However I agree with you that it is not within the Unix philosophy. uniq
did not have that option (and sort
did not have a -u
then).
On my PDP-11 I used a small program that would take one parameter:
renac whatever
If whatever
already existed, it would write everything from stdin to a temporary file, that was only renamed to whatever
after the stdin input dried up. That way you could pipe the output of any command into renac
instead of redirecting to the filename without a chance of overwriting the input. Solving the overwriting problem in that way is IMHO more conform to the Unix philosophy.
Some later additions to the program were: not overwriting the output file if nothing had arrived on stdin (e.g. a result of mistyping part of the commandline), and allowing an option to append stdin to the named file.
This was one of the first (if not the first) real C programs that I made (for my job I mostly developed in Pascal on that system).