The core issue here is how the shell (bash ) does quoting and how that affects tilde expansion and splitting into “words” (arguments for the program being run).
bash only treats the leading tilde specially if it is not quoted. In addition, the following slash must also not be quoted.
At the same time, bash parses command lines into “words” based on non-quoted whitespace. The cd command typically requires exactly one argument (the destination directory). A command line like cd foo bar means to run cd with two arguments: foo and bar. If you only wanted to send a single foo bar argument, then you need to quote the space:
(e.g.) cd foo\ bar (see more quoting example below).
In your particular situation, you need to leave the tilde and the following slash unquoted while quoting the space in the
directory name. Your cd "
/Library/Application Support/" trial ends up quoting too much (the tilde and its slash), while your cd
/Library/Application Support/ trial quotes too little (it omits quoting the space in the directory name).
The most common solution is to use single-character escaping to quote just the space:
You can also use single or double quotes around either just the space or the space and some other bits of that argument (but not the
These kinds of quotes have different meanings, but they are identical in these examples. Single quotes protect literal strings while double quotes allow various expansions and substitutions in the quoted region.
Often, you can just let the shell do the work for you.
You can use shopt -s nocaseglob to make globbing case insensitive: