bash 命令 XOR ^ 另一个命令
bash command XOR ^ anothercommand
在下面的例子中:
w ^ ls
XOR 运算符在 shell 中的预期行为是什么?
所以当我们输入
command ^ anothercommand
什么触发 anothercommand
到 运行(如果它会执行)?
正如你在man bash
中看到的,^
不是用来分隔命令的,而是用在算术表达式中。
$ echo $(( 5 ^ 9 ))
12
那是因为
dec bin
5 0101
9 1001
-----------
12 1100
如果您输入 command ^ anothercommand
,您只是向 command
提供两个参数,^
和 anothercommand
。这里没有接线员。 anothercommand
只会 运行 如果 command
决定将该参数视为命令名称并尝试 运行 它。
在下面的例子中:
w ^ ls
XOR 运算符在 shell 中的预期行为是什么?
所以当我们输入
command ^ anothercommand
什么触发 anothercommand
到 运行(如果它会执行)?
正如你在man bash
中看到的,^
不是用来分隔命令的,而是用在算术表达式中。
$ echo $(( 5 ^ 9 ))
12
那是因为
dec bin
5 0101
9 1001
-----------
12 1100
如果您输入 command ^ anothercommand
,您只是向 command
提供两个参数,^
和 anothercommand
。这里没有接线员。 anothercommand
只会 运行 如果 command
决定将该参数视为命令名称并尝试 运行 它。