Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Let say my current directory in terminal is ~/Users/Desktop. On my desktop, there's a folder called "sample_dir". How can I cd in this "sample_dir" folder with typing: "cd ~/Users/Desktop/sample_dir"? There's gotta be a shorter way that looks at your current directory and appends that path to the directory you pass in to make things faster.

Thanks

share|improve this question
add comment

migrated from stackoverflow.com Dec 21 '11 at 14:30

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

4 Answers

up vote 6 down vote accepted

There is. Type:

cd sample_dir

It checks for you. If for some strange reason that doesn't work, type:

cd ./sample_dir
share|improve this answer
add comment

The path you are using cd ~/Users/Desktop/sample_dir is wrong.

If you have a folder named sample_dir in you user's Desktop directory then the full path to the directory is:

cd /Users/YourUserName/Desktop/sample_dir

Where YourUserName is the the short account username. Using the tilde ~ shortcut to your home directory this can be shortened to

cd ~/Desktop/sample_dir

When you open a new terminal session you start in your home directory, so:

cd Desktop/sample_dir
share|improve this answer
add comment

I usually type cd, then drag the folder (from Finder) that I want to open in Terminal, and drop it in Terminal. This will add the full directory path, then press enter to change to the dropped directory.

share|improve this answer
add comment

Typing cd sample_dir should work... check "pwd" to make sure the current path is what you expect.

share|improve this answer
    
hmm let me try, pretty sure it doesn't work. –  PragmaOnce Dec 21 '11 at 6:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.