-2
> #># cat /etc/group > test
> #># cat < test > test
> #># cat test

I inputted the second command in prompt and checked the test file. I found that test_file was empty.

Why does it happen?

Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42
hyunjung
  • 23
  • 2
  • Possible duplicate of [How can I use a file in a command and redirect output to the same file without truncating it?](https://stackoverflow.com/q/6696842/608639), [input and output redirection to the same file](https://stackoverflow.com/q/29899654/608639), etc. – jww Apr 12 '19 at 01:54

1 Answers1

0

My guess is that you are redirecting test > test first but the result of this declaration gives an empty test file. And then you redirect this empty test file with cat < test which displays this empty file.

That's why your second and third command print nothing.

Maxime
  • 838
  • 6
  • 18