os x terminal unix commands

I forgot how to change directories when the directory name or file name is more than one word with a space between the words. For example, when I type "cd Pictures" then use the "ls" command to see the folders or files there is a directory My Pictures ( I know it's a directory because I used "ls -all" ) but when I try to use the command "cd My Pictures" then the return messages is "no such file or directory". What did I forget?

Forward slash ('/') is the directory separator. Normally in Unix shells, spaces are used to separate arguments. So if you want to add a space to an argument you must add the escape character ('\') before the space. That's why the backslash is there.

Forward slash ('/') is the directory separator. Normally in Unix shells, spaces are used to separate arguments. So if you want to add a space to an argument you must add the escape character ('\') before the space. That's why the backslash is there.

Click to expand...

thank you, another question is how does this usage relate to a filename that includes a parenthesis such as '(' or ')' ??? I have tried to use the backslash in a filename to determine some characteristics of the filename but the shell tells me that there is an unrecognized token near the (. However it did not seem to have any problem with the '-' character.

Yes, the parenthesis is a special character. As ar braces {} and brackets []. Normally you shouldn't have to worry since TAB-completion will help you out. As you type commands, put in the first couple of characters of a file and press TAB. The shell will complete the rest of the filename as best it can. If the filename includes special characters, the shell will automatically insert the escape characters.

thank you, another question is how does this usage relate to a filename that includes a parenthesis such as '(' or ')' ??? I have tried to use the backslash in a filename to determine some characteristics of the filename but the shell tells me that there is an unrecognized token near the (. However it did not seem to have any problem with the '-' character.

Thanks for your assistance.

Click to expand...

When you ask a question about a command line, please provide the exact command-line used, and the exact text of any error messages. You can select text in a Terminal window, then copy it to the clipboard and paste it into a post. It's difficult to guess exactly what you may have typed when all you provide is a vague description.

If you want to see what you should type for any pathname, you can use the 'echo' command, then a space, then drag and drop the desired file from the Finder onto the Terminal window. The full path will then be automatically typed in, with the necessary \'s in the required places.

The 'echo' command simply echoes its args, but it does so after the \'s and quotes have been removed, wildcards expanded, etc. So you can simply press RETURN at that point to see what the actual filename will be.

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.