I issued the following command, thinking it would take the contents of foo.txt, process it, and write it back to the original file. Instead when I opened the file, it was empty.
cat foo.txt | tr " " "\n" > foo.txt
What exactly is going on in this line, and how can I rephrase it to redirect output back to foo.txt?