Linux Command Line – Files And Directories With Spaces
Filed under Tutorials
While normally I name all of my folders and files with ‘-’ or ‘_’ instead of spaces sometimes you need to access a file/directory that has spaces in its name.
People new to Linux will quickly realise that trying to do :
cd My Folder
At the command line will result in :
bash: cd: My: No such file or directory
There are two common ways to get around this problem.
The first method is to quote the name of the file or folder :
cd 'My Folder'
Notice the single quotes surrounding the folder name.
The second method is called escaping. This is where you but a backslash followed by the special character.
cd My\ Folder
Above the space is replaced with a backslash followed by a space.
There you have it now you should be able to use files and folders with spaces in the name using the Linux command line.
Aug06