[英]Cat command with redirection results in an empty test file
> #># 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.我发现
test_file
是空的。
Why does it happen?为什么会发生?
My guess is that you are redirecting test > test
first but the result of this declaration gives an empty test file.我的猜测是您首先重定向
test > test
但此声明的结果给出了一个空的测试文件。 And then you redirect this empty test file with cat < test
which displays this empty file.然后你用
cat < test
重定向这个空的测试文件,它显示这个空文件。
That's why your second and third command print nothing.这就是为什么您的第二个和第三个命令不打印任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.