Situation: When using the following command:
cat foo | sort | tee foo
foo is a text file of multiple lines, the outcome is not consistent. The two outcomes I've observed are:
- The file is sorted, and the sorted contents are printed to stdout.
- The file is emptied, and nothing is printed.
Question: Why does this happen?
P.S. I realize that
sort has a
-o option on my system.