How to cd when space character is in directory name

I looked online to find an answer to this question, but to no avail. Did a search on this site but found nothing.

I am new to nixCraft and Unix. On my macOS. I have a directory named ‘Application Support’. Yes, there is a space character in there. When trying to use ‘cd’ to get into it I get an error.

cd Application Support
bash: cd: Application: No such file or directory

I know that the space character is used to separate arguments so how do I tell ‘cd’ that the space is part of the directory name? I tried single and double quotes and escape with a ‘’. Same error.

This directory was created when I installed an app. I need to see inside that directory to fix an issue. Using Finder doesn’t even see that directory.

Thanks for any help.

Boyd

Try enclosing directory name in double or single quote:

cd "Application Support"
cd 'Application Support'

Another option is:

cd Application\ Support/

Another trick is to autocomplete folder/dir names, type cd and first few characters of folder and hit Tab key:

cd "App [Press TAB key]"

Thanks. All four methods worked. I had tried the two with both single and double quotes but for some reason they didn’t work. Now they do. I am new to Unix so may have made some other mistake.

Learned much from your answer. Very much appreciated.

Boyd


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki