bash command XOR ^ anothercommand
Solution 1
If you enter command ^ anothercommand
, you are simply providing command
with two arguments, ^
and anothercommand
. There is no operator here. anothercommand
will only run if command
decides to treat that argument as a command name and attempt to run it.
Solution 2
As you can see in man bash
, ^
is not used to separate commands, it's used inside arithmetic expressions.
$ echo $(( 5 ^ 9 ))
12
That's because
dec bin
5 0101
9 1001
-----------
12 1100
AK_
I'm very passionate about software engineering and security, I tend to answer questions related to: Algorithms & Data Structures: Optimization and making things go faster.. e.g: O(n) -> O(Log(N)) C/C++ & C# Objective-C and iOS Development tricks in general. Python. If you would like to contact me directly use this link.
Updated on March 01, 2020Comments
-
AK_ about 4 years
In the example below:
w ^ ls
what's the expected behaviour of the XOR operator in shell?
So when we enter
command ^ anothercommand
what triggers
anothercommand
to run (if it will execute at all)?