Move Into a Directory

Discussion in 'Mac Programming' started by crtvmac, Mar 18, 2010.

  1. crtvmac Guest

    Joined:
    Aug 14, 2009
    #1
    I am having a problem getting into my directories from the Terminal window using Mac. When I type ls -F, I get a list of my directory's with the / before the directories. Then I type cd and the name of the directory I am trying to get into. When I do that command, i keep getting "-bash: cd: Java: Not a Directory" or "No such file or directory". Will someone tell me what I am doing to not be able to get into any of my directories?
     
  2. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    Two things for our enlightenment.

    Please post the results of issuing the 'alias' and 'cd /' commands from the Terminal.
     
  3. iShater macrumors 604

    iShater

    Joined:
    Aug 13, 2002
    Location:
    Chicagoland
    #3
    I'm not sure if bash changed that much from 10.5 to 10.6, but that is not the error message I get:

    file1: Not a directory.
    or
    file: No such file or directory.


    Can you give an example of a directory name from your ls command and what you are passing to the cd command?
     
  4. crtvmac thread starter Guest

    Joined:
    Aug 14, 2009
    #4
    My mistake. The '/ ' is after the directory I am trying to get into.
     
  5. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #5
    Are there spaces or other whitespace in the directory names?

    If so, you need to escape them either with backslashes or quotes.

    I always find the easy way is to use tab completion.

    i.e. type cd and if you want to go to folder "Java Code" type J then tab until the right name is shown.

    B
     
  6. crtvmac thread starter Guest

    Joined:
    Aug 14, 2009
    #6
    I'm running 10.6.2.
    Example from 'ls' command: 'Java Learning/'
    Example from 'cd' command: 'cd Java Learning'
     
  7. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #7
  8. iShater macrumors 604

    iShater

    Joined:
    Aug 13, 2002
    Location:
    Chicagoland
    #8
    It is a space issue most likely.

    As the suggestion above says, type the cd command and the first word of the folder name then hit the ESC key twice/or hit TAB once, it will auto complete for you. You will see that it uses some escape characters.

    You can also use " quotes around the name.

    Edit: Tab completion and ESC both work.
     
  9. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #9
    If you choose not to use command line completion you just need to wrap it in quotes yourself.

    cd "Java Learning"/

    or

    cd Java\ Learning/

    EDIT: you learn something new everyday. I didn't realize you could use either single or double quotes and double ESC instead of TAB.

    B
     
  10. iShater macrumors 604

    iShater

    Joined:
    Aug 13, 2002
    Location:
    Chicagoland
    #10
    I actually forgot about the TAB, thanks for reminding me. :)
     
  11. crtvmac thread starter Guest

    Joined:
    Aug 14, 2009
    #11
    I used the quotes as you suggested and was able to get into my selected directory. Thank you for the assistance.
     

Share This Page