The &
operator sends a process to background; as cd
can be run without arguments you are running it and sending it to background. If you take the man page:
NAME
cd - Change the shell working directory.
SYNOPSIS
cd
[-L
|-P
] [dir]
DESCRIPTION
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the HOME
shell variable.
The variable CDPATH
defines the search path for the directory containing
DIR. Alternative directory names in CDPATH
are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/
), then CDPATH
is not used.
If the directory is not found, and the shell option cdable_vars
is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.
Options:
-L
force symbolic links to be followed
-P
use the physical directory structure without following symbolic
links
The default is to follow symbolic links, as if -L
were specified.
Exit Status:
Returns 0 if the directory is changed; non-zero otherwise.
SEE ALSO
bash
(1)
IMPLEMENTATION
GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
You can see the arguments are optional. So
cd &
is processed as
cd
and then send to background. When cd
is called with no argument no processing is needed. So it goes to background as "done" (processed).
Some info regarding &
The Bash &
(ampersand) is a builtin control operator used to fork processes. From the Bash man page, "If a command is terminated by the control operator &
, the shell executes the command in the background in a subshell".
If logged into an interactive shell, the process is assigned a job number and the child PID is displayed. The job number below is one.
bash$ sleep 30 &
[1] 3586
Note that when a process is forked, the child PID is stored in the special variable $!
bash$ echo $!
3586
You can terminate the job by its job number like so:
bash$ jobs
[1]+ Running sleep 30 &
bash$ kill %1
[1]+ Terminated sleep 30
bash$
cd <TAB>
and the name of the unique folder will be expanded automatically.