How to write the path of a folder with space in its name? [duplicate]
I can't figure out how to write the path of a folder that includes spaces in its name (in Terminal).
I tried:
cd /path/path/path/"A Folder"/file
cd /path/path/path/'A Folder/file
cd /path/path/path/A_Folder/filebut they all return the error through the terminal:
[command]: cannot access '/path/path/path/A Folder/file' No such a file or directory I can still access it through steps like so:
cd /home
cd user
cd Desktop
cd "Bash Programming"
bash Example 2 4 Answers
You can enclose the whole path by double-quotes ("), single-quote (') or escape the space character using a backslash (\) :
cd "/path/path/path/A Folder/file"
cd '/path/path/path/A Folder/file'
cd /path/path/path/A\ Folder/file 2 Either quote the entire name:
cd "/path/path/path/A Folder/file"or escape just the strange characters (space, in this case) using a backslash.
cd /path/path/path/A\ Folder/fileAnother thing to try, is using tab completion:
cd /home/user/Desktop/BasThen press the TAB key, this should complete it to:
cd /home/user/Desktop/Bash\ Programming/Then you can type the rest of the path.
1Have you tried this?
cd Bash\ ProgrammingOr
/path/path/path/A\ Folder/file either put all or partial path in single or double quote or escape space with backslash.
Eg:
cd /path\ to\ folder
cd '/path to folder'