Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am beginner to the Mac command line interface.

For example I want to go to directory "how are you".

But when I type cd how are you, it is avoided. When I change the name to be without space, howareyou to the directory, it works. Any help?

And also how to create an AppleScript script to go to particular a directory?

share|improve this question

migrated from stackoverflow.com Nov 2 '09 at 15:06

This question came from our site for professional and enthusiast programmers.

    
Should be on superuser.com – Tim Büthe Nov 2 '09 at 9:13
    
@senthilmuthu, after using the same OpenID here at superuser.com, you can associate your accounts at stackoverflow.com/users/141302?tab=accounts – Arjan Nov 2 '09 at 17:22
    
Spaces - the final frontier! superuser.com/questions/29111/… – Chris W. Rea Nov 2 '09 at 19:23
up vote 7 down vote accepted
cd 'how are you'

Or,

cd how\ are\ you
share|improve this answer
    
thanks ..tutorial to write applescript pls – senthilmuthu Nov 2 '09 at 9:15
    
You are welcome. Try: google.com/search?q=applescript+tutorial – Alan Haggai Alavi Nov 2 '09 at 9:18
    
hi i want to go to cd \Desktop\senthilmuthu\SenthilmuthuSoftwares\check this says no directory...any help – senthilmuthu Nov 2 '09 at 12:24
2  
This is not \ but / This is not /Desktop/... but ~/Desktop/... – mouviciel Nov 2 '09 at 13:46
2  
@bert, using %20 is not a standard Unix way. That is "percent-encoding", as used in URLs: en.wikipedia.org/wiki/Percent-encoding – Arjan Nov 2 '09 at 17:20

And to avoid problems, use Tab to automatically complete the name for you. Like if you have three directories in your home folder, ~/:

  • "how are you"
  • "how are we"
  • "how is she"

Then:

  • type "cd ~/h", press Tab; this yields "cd ~/how\ " and a beep, telling you there's more
  • optionally: press Tab again, to see the list of matching names
  • next, type "a", press Tab; this yields "cd ~/how\ are\ " and a beep
  • optionally: press Tab again, to see the list of matching names
  • next, type "y", press Tab; this yields "cd ~/how\ are\ you/"

(Funny: the rendering of the backtick is slightly different in text and in lists. Favouring lists then...)

share|improve this answer

If you simply want an AppleScript to change it's current working directory, it isn't possible for the entire script as do shell script "uses a new shell process, so state such as changes to variables and the working directory is not saved from one to the next." (Source)

do shell script 'cd /PATH/TO/DIRECTORY/; more commands here'

If you want to use AppleScript to open up and change to the directory in Terminal:

tell application "Terminal"
    activate
    do script "cd /PATH/TO/DIRECTORY"
end tell
share|improve this answer
    
I doubt the first really changes the working directory of the AppleScript? osascript -e 'do shell script "cd ~/Desktop/"' -e 'do shell script "pwd"' (That second example works fine though; osascript -e 'tell application "Terminal"' -e 'activate' -e 'do script "cd /PATH/TO/DIRECTORY"' -e 'end tell') – Arjan Nov 2 '09 at 17:09
    
@Arjan van Bentem - I've added some clarification and a correction. Thanks! – Chealion Nov 2 '09 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .