【发布时间】:2020-09-20 14:21:34
【问题描述】:
为什么会得到不同的结果?分配变量a 时真正发生了什么
shell文件内容为
ls
a=`cat 2 3 1>/dev/pts/0 2>/proc/self/fd/1`
echo ------$a--------1
a=`cat 2 3 2>/proc/self/fd/1 1>/dev/pts/0`
echo ------$a--------2
当执行 shell 时,它会输出
[root@VM-0-17-centos ~]# sh test.sh
2 dump.rdb node-v12.18.3-linux-x64.tar.xz test.sh
hello
cat: 3: No such file or directory
--------------1
hello
------cat: 3: No such file or directory--------2
【问题讨论】:
-
你的问题真的很糟糕。请在您的问题中包含所有必要信息以及重现问题所需的所有步骤。请在发布前检查您的问题。请创建一个MCVE。请阅读how to ask a good question。我猜
2文件的内容是hello。