Terminal Help

Discussion in 'Mac Apps and Mac App Store' started by Darbydoggy, Oct 4, 2004.

  1. Darbydoggy macrumors newbie

    Joined:
    Aug 29, 2004
    Location:
    California
    #1
    I need some basic understanding or help with Terminal that I don't get. I am the only user on my PB (and thus the OS X admin). In Terminal, I can cd to any existing folder that was there when I first started with the OS (ie-any pre-existing folder). I can't, however, cd to any new folder that I created. For example, I can cd to Documents, and when I ls I see all the subfolders listed that I have created. When I cd to one of those subfolder I get an error in Terminal as follows:

    -bash: cd: Ipod: No such file or directory

    For a full example, here is an entire short sequence from Terminal that shows what I mean:

    Pete-Computer:~ Pete$ cd Documents
    Pete-Computer:~/Documents Pete$ ls
    Ipod Info Pete's Documents
    Pete-Computer:~/Documents Pete$ cd Ipod Info
    -bash: cd: Ipod: No such file or directory
    Pete-Computer:~/Documents Pete$

    Can anybody explain why, or tell me if this is normal and how I can access newly created directories in Terminal?

    Thanks!
     
  2. bousozoku Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #2
    If you have folders/directories with spaces in the name, use quotation marks around the name, so it knows to use everything.

    cd "Documents/Ipod Info" will get you there

    or even,

    cd "Documents"
    cd "Ipod Info"
     
  3. Darbydoggy thread starter macrumors newbie

    Joined:
    Aug 29, 2004
    Location:
    California
    #3
    Thank you! That was it. I mistakenly thought it had to do with newly created folders, but I was only trying folder names that had spaces in them. I have a LONG WAY TO GO with my learning of some Unix, then understanding some obj C and then playing with Cocoa. :)
     
  4. bousozoku Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #4
    I'm sure you have plenty of company also getting a history lesson in UNIX. :D Imagine all those MS-DOS/PC-DOS users who thought they knew how to use the command line--they're learning too.
     
  5. tomf87 macrumors 65816

    tomf87

    Joined:
    Sep 10, 2003
    #5
    Anothery way to make note of is to use the backslash:

    cd Documents
    cd Ipod\ Info

    If you go into Terminal and do:

    cd Document
    cd Ipod<hit Tab now>

    On that second line, if you hit the Tab key, it will try to autocomplete it for you as well.
     
  6. bousozoku Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #6
    You should mention that you use a backslash to form an escape character and that it works with several of the things that normally can't be typed outright. ;)
     
  7. bankshot macrumors 65816

    bankshot

    Joined:
    Jan 23, 2003
    Location:
    Southern California
    #7
    Another tip: type a little bit of the file or folder name (enough to be unique) and hit the tab key. It'll expand the rest of it for you. If what you didn't type is fully unique (for example, you just typed 'a' and there are 5 files starting with 'a'), it will beep at you once. Hit tab a second time and it will list all the possibilities for you. Very handy!
     
  8. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
  9. Darbydoggy thread starter macrumors newbie

    Joined:
    Aug 29, 2004
    Location:
    California
    #9
    Thanks again to everybody. I found the OSXFAQ site late last night and will be reading through it. Apple users are the best!!
     
  10. zimv20 macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    toronto
    #10
    wow, i learn something new every day.

    i've been using filename autocompletion for 20 years, but i always use the escape key (hit it twice). is the tab autocompletion an Apple thing, or did that creep into various versions of unix when i wasn't looking?
     
  11. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #11
    It's part of tcsh (and probably bash) across all UNIX platforms (at least Darwin, Solaris, and OSF, the only ones I've used it on lately) for quite a while.
     
  12. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #12
    Here's another handy Terminal tip. Hit Control+R while at a BASH prompt, and you'll get a "reverse-i search" prompt. Start typing, and BASH will search the list of recently typed commands for the one you're looking for. When you find the one you want, press Return to accept it. You can edit it before running it by pressing Return again.
     
  13. cluthz macrumors 68040

    cluthz

    Joined:
    Jun 15, 2004
    Location:
    Norway
    #13
    Thanks wiz!

    Using terminal all day, but have never used the reverse-i search.
    This would save me a lot of time! (hehe, atleast 30 sec a day maybe.. :D )

    Anyway is it possible to launch apps from the terminal like you do on gnu/linux and others unixes? like >mozilla & (i know the & is to not occupy the latest xterm seesion).
    I know i can run >open Mozilla.app (if Mozilla.app is in pwd.), but that takes too muck time to do.
    I know that files added to the $PATH can be run like this. But ".app"s are folders and i don't think it would work if i added /Applications/ to $PATH either
     
  14. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #14
    open -a Mozilla

    No need for it to be in your path. I beleive as long as it's in the /Applications and/or /Applications/Utilites.
     
  15. cluthz macrumors 68040

    cluthz

    Joined:
    Jun 15, 2004
    Location:
    Norway
    #15
    Sweeet. :cool:
    No need for launchbar or quicksilver now...
     
  16. cluthz macrumors 68040

    cluthz

    Joined:
    Jun 15, 2004
    Location:
    Norway
    #16
    Now i don't have to use vi to edit invisible files (like different configfiles)!!!

    open -a subethaedit .profile :D

    Is this standard unix? Or a macosx thing?

    The posibilities and how powerful the terminal in macosx is, are often well hidden.
    Osx is far more powerful than any other OS i have used.
    With the X11 server and OSX own functions you can run everything (except win only progs, hope the DarWine project will get a breakthru soon).
    Most OSX users doesn't discover the possibilities you have.
     
  17. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #17
    It's Mac OS X-specific. Actually, if you want to edit something, you use the -e switch to open:

    open -e .profile

    ...and Mac OS X opens it in TextEdit so you can modify it. I don't see any reason why:

    open -a (application) (file)

    ...wouldn't work, but I haven't tried it. By the way, you can't combine -a and -e. You'll just get an error message if you try.
     
  18. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #18
    I believe you can also couple this with sudo.

    Though, just testing, it replaces the permissions with those of your own, so this might not be such a useful thing.
     
  19. cluthz macrumors 68040

    cluthz

    Joined:
    Jun 15, 2004
    Location:
    Norway
    #19
    open -a (app) (file) works great!
     
  20. osprey76 macrumors 6502

    Joined:
    May 3, 2004
    Location:
    Oklahoma City, OK
    #20
    Nice! I'll have to try this tonight (on a PC at work.) I've used the single-Tab for a long time (not that I'm a big Terminal guru) but didn't know about the double-Tab option.
     
  21. cluthz macrumors 68040

    cluthz

    Joined:
    Jun 15, 2004
    Location:
    Norway
    #21
    while were talking about terminal commands.
    I have a machine here which holds my whole household's mp3 files.
    I mount a HD partition from this machine on my powerbook and have my iTunes library on this partition.
    The problem is that sometimes when we add files (with itunes) to this mp3 folder from different computers and different users the permissions get bad and some users can't rename/organize the files which has get limited permissions.
    my solution has been to use:
    >sudo chmod 777 * //and then:
    >sudo chmod 777 */*
    Then i have fixed the firectory For "Artist" and "Album", but no the Songs.
    The problem is whan i run:
    >sudo chmod 777 */*/*
    I get a warning that argument list is too long...
    Ofcourse of i can use a*/*/*, and then b*/*/*, but it takes too long time.
    I tried to check the "ignore permissions on this volume", but it didn't work that well either.
     
  22. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #22
    First of all, you shouldn't be setting execute permissions on the song files. The reason you're getting that warning is that you're running into an internal limit on the length of command-line arguments in Mac OS X, which is 65535 characters. Odds are that when that expression is fully expanded, the resulting text is too long for Mac OS X to handle. The easiest way to do this is to write a little shell script that changes to each directory and changes permissions on everything in it. You'll need to make use of the pushd and popd commands so you can keep track of where you've been and where you need to go next.
     
  23. cluthz macrumors 68040

    cluthz

    Joined:
    Jun 15, 2004
    Location:
    Norway
    #23
    :eek: yeah i guess the permission should be 666 (110 110 110) instead of 777.

    I'm not much into scripting (yet),
    but isn't it possible to record a executable script?
    (like the >script "output.txt")
     
  24. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #24
    I'm not entirely sure what you're talking about, but you can record a UNIX command's output like so:

    command > file

    If you want to record error messages:

    command 2> file

    You can even do this:

    command | tee file

    What that does is displays the output of 'command' on the screen, and ALSO records it to 'file'.
     
  25. bankshot macrumors 65816

    bankshot

    Joined:
    Jan 23, 2003
    Location:
    Southern California
    #25
    No need to go writing a shell script when a simple command will suffice:

    Code:
    sudo find . -type f -exec chmod 666 {} \; -print
    For the folders, use -type d (d for directories) and mode 777.

    That said, the Unix security alarms in my head are going off like mad looking at these permissions. :eek: :p My inclination would be to create a group that includes all the users who need to access the music files, change all the files/directories to be owned by that group, and make the permissions 664 (or 775 for directories). Left as an exercise for the reader unless you seriously want to try it. Then I'll be happy to go into more detail. ;)
     

Share This Page