I am baffled by this example:
[ziga@brane ~]$ touch test.txt
[ziga@brane ~]$ echo "TEST" > test.txt
[ziga@brane ~]$ cat test.txt
TEST
[ziga@brane ~]$ cat test.txt | grep "TEST"
TEST
[ziga@brane ~]$ cat test.txt | grep "TEST" > test.txt
[ziga@brane ~]$ cat test.txt
[ziga@brane ~]$
Why does cat test.txt | grep "TEST" > test.txt delete contents of a file test.txt? I thought that > rewrites and >> appends! What am I missing?