What is the difference between &> and >& in bash?
The shell uses spaces to separate the command to run and its parameters.
In the first example, the command to run is .
with a parameter of a.out
. The .
command is a shell shortcut for source
, which takes the name of a file containing shell commands as its first parameter and runs those commands in the current shell. This command fails because a.out
is a binary file, not a shell script.
In the second example, the command to run is ./a.out
, which means run the file a.out
residing in the current directory.
./program
runs a file namedprogram
located in your current working directory (./
) (in a new shell for a shell script)..
is the same assource
, which runs a shell script in your current shell. Unlike./program
, it can't be used to run binaries! As an example, you could use this command to run your.bashrc
shell script, because you want this script to modify your current shell.