The shell performs word splitting on arguments before passing it them to the command you specify. This means it takes the line (or, in some cases, lines) and splits it apart into several words, by default at spaces, tabs, and newlines.
As Lưu Vĩnh Phúc mentioned, backslashes and single quotes can be used to prevent word splitting on single characters or everything between them, respectively. Double quotes also work:
cd "October Fall"
In this particular case,
" behave identically, but they do have differences.
' disables all special character interpretation (even
\), but cannot contain a
" only disables word splitting and file name expansion (file name expansion is things like
ls *.mp3 to list all files with names ending in
* triggers the file name expansion here). Since
" allows some argument expansions, it's useful if, for example, you have a file name with a space in it inside a variable:
$ filename=October\ Fall
$ # ^-- Still need a backslash or quoting to prevent word
$ # splitting here, but the backslash/quotes will not be stored
$ cd $filename
bash: cd: October: No such file or directory
$ cd '$filename'
bash: cd: $filename: No such file or directory
$ cd "$filename"
" do not (by default) cause word splitting themselves, so this, despite being messy, would work for you:
cd "Oct"'ober F'"all"
This is useful if you've got something such as a directory named
Octobers' $HOME. The
' in it would break a single pair of
' quoting, and inside
$HOME will expand to your home directory. But any of these combinations (and many others) will work safely:
cd Octobers\'\ \$HOME
cd "Octobers' "'$HOME'
cd "Octobers' "\$HOME
cd "Octobers' \$HOME"
Something else to keep in mind is that many modern shells offer tab completion. Both Bash and Zsh (probably Ksh as well, but I haven't tested it) can expand part of a directory's name to its full name, complete with safe escaping via
cd Octobers<tab> becomes
cd Octobers\'\ \$HOME. You may have to press tab multiple times if there are multiple matches. Also, your shell may not have tab completion enabled by default, check your shell's documentation.