当我在bash中运行一个简单的cmd时,我得到了:
$echo 12312> aaa.txt
-bash: 12312: Bad file descriptor
$lsof aaa.txt
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 20647 root 4r REG 8,1 0 1409118 aaa.txt
$bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$uname -a
Linux node39 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
这里有错误吗?我对bash源代码不熟悉,但是我想 知道为什么。因此,请给我一些提示,最衷心的希望是您。
编辑: thx回答我的问题,但我真的很想知道为什么aaa.txt仍然由 错误发生后立即重击。
答案 0 :(得分:2)
spaces
-bash对空格非常具体
echo 1234 > output.txt
将上述示例1234
使用重定向操作符output.txt
写入>
echo 1234> output.txt
重定向运算符会将1234
视为"file descriptor number"