Possible Duplicate:
How can I make iconv replace the input file with the converted output?
Can I read and write to the same file in Linux without overwriting it?
$ cat test.txt
This is a test file.
$ tr 'a' 'z' < test.txt
This is z test file.
$ tr 'a' 'z' < test.txt > test.txt
$ cat test.txt
$
Why does tr seem to output nothing to test.txt? I found this thread, but I don't really understand what is going on, and how to fix the problem.
(Also, the reason I'm not using sed is because I want to replace newlines with another character, and I don't think sed can operate on a non-line-by-line basis?)