Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Change directories in Terminal

Jul 15, 2012 12:43PM PDT

I have a new file placed ("fileX") in what I think is my "Home" directory -- the space where the Documents and Movies and Applications sit. However, when I go to the Directory space and give the "cd fileX" command, it tells me the file is not recognized. What am I doing wrong?

Discussion is locked

- Collapse -
Answer
Did you try chdir?
Jul 15, 2012 12:51PM PDT
- Collapse -
chdir command doesn't exist
Jul 16, 2012 2:04AM PDT

I did try it, but my MacPro tells me the command doesn't exist. When i do the 'cd' command followed by the filename, it tells me that the *file* doesn't exist. So i'm wondering (from my Windows experience) whether i need to specify a PATH to that file. As i said, i placed it in what seems to be the "Home" directory, where documents, movies, and applications also sit.

- Collapse -
Is this a new problem?
Jul 16, 2012 2:13AM PDT

As in, "it worked before?"

I can't tell if you are new to the UNIX command line or not. Before I could cd years ago I had to alias cd to the chdir command. And if you are new to UNIX in general, my last sentence would not make any sense.

So without knowing where you are in your journey I suggest you ls first so you can see the names of the folders before you try to cd there. And in all known UNIX case matters. Home is not the same as home.

Sorry but you may have to reveal a little here.
Bob

- Collapse -
New to Unix
Jul 16, 2012 7:20AM PDT

I have no particular background in UNIX. I am used to working in a Windows environment, with the c:\ prompt at the base level. The instructions i'm working with are for learning the programming language Python in a Mac environment. Here is the instruction we're responding to:

MacCreate a folder on your computer to use for your Python programs. A good suggestion would be to name it pythonpractice and place it in your Home folder (the one that contains folders for Documents, Movies, Music, Pictures, etc). Save your hello.py program into this folder.Open the Applications folder, go into the Utilities folder, and open the Terminal program.Type cd pythonpractice to change directory to your pythonpractice folder, and hit Enter.Type python hello.py to run your program!

<div>This is found under the "Mac" heading in:


http://en.wikibooks.org/wiki/Python_Programming/Creating_Python_programs

</div>
I've done all this successfully in my 'home' system of Windows, and now am trying to help my son who's using a Mac Pro. Thanks for trying to help!

- Collapse -
new to Unix
Jul 16, 2012 7:25AM PDT

Yes, i'm basically a Windows guy. I'm trying to help my son learn some Python programming. Here's the instruction we're responding to, under
http://en.wikibooks.org/wiki/Python_Programming/Creating_Python_programs

MacCreate a folder on your computer to use for your Python programs. A good suggestion would be to name it pythonpractice and place it in your Home folder (the one that contains folders for Documents, Movies, Music, Pictures, etc). Save your hello.py program into this folder.Open the Applications folder, go into the Utilities folder, and open the Terminal program.Type cd pythonpractice to change directory to your pythonpractice folder, and hit Enter.Type python hello.py to run your program!


Thanks a lot for trying to help!

- Collapse -
Link, comment
Jul 16, 2012 7:47AM PDT
http://www.python.org/getit/mac/ may be out of date but it appears you don't need to install python.

Now that we know where you are in the process try

pwd

To see what your current folder is. And

ls

Or

dir

To see what's in that folder that you are in. You can't cd to a folder that isn't there.
Bob
- Collapse -
Python help
Jul 27, 2012 12:13PM PDT

Thanks for our help, Bob. My son finally figured it out.

- Collapse -
Answer
Also.
Jul 15, 2012 12:52PM PDT

If a folder has a space in it, you can quote it.

chdir "this folder"