Tuesday, March 23, 2010

Working with files and folders that has spaces in their names


I was in OSX's terminal yesterday trying to cd into a folder with a space in the name. That usually works really well with tab-completion but in the same place in the directory tree there were  another folder with the same name but without the space.

Here's a little illustration to clarify what I just wrote.  

root--+
      |
      +--Folder1 
      +--Folder1 With Space

So I want to cd into "Folder1 With Space" but I can't use tab-completion or type: 
cd Folder1 With Space 

However I can use \ as the escape character:
cd Folder1\ With\ Space

I can also use quotes, 'normal' or "double" (useful if the folder uses either one in it's name).
cd 'Folder1 With Space'
cd "Folder1 With Space"



Although I haven't tried it I'm pretty sure this works in any *nix terminal. 

No comments:

Post a Comment