I tried the following command $cat < text > text
where text
is a non-empty file.
There was no output to stdout and the file text
became blank. I expected cat command to read the file text and output the contents to the same file.
However when I try $cat < text > newtext
it works! newtext
is a copy of text
.
Another doubt, When I try $cat < text >>text
where >>
usually appends to a file. My terminal gets stuck in an infinite loop and file text
is repeatedly appended to itself. Why does this happen?