Terminal program

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

  1. crtvmac Guest

    Joined:
    Aug 14, 2009
    #1
    I am in the process of learning to use the Terminal program in Snow Leopard. When I try to delete a directory I created called 'Test', using the command line code
    ' rm -d -i Test' , it wont delete. When I type return, the terminal displays 'remove Test?'. I then type 'y' and return. I then get 'rm: Test: Directory is not empty'. The 'Test' directory is empty though. I did the 'open .' command and checked in the window that was displayed. Will someone please tell me where I am going wrong, so I can delete the 'Test' directory?
     
  2. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #2
    you want

    Code:
    rm -r /path/to/Test
    (PS: if you Google your question first you'll get an answer without having to wait)
     
  3. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    what about a little ls -al action in the directory to be deleted? maybe there are some hidden files in there.

    -Lee
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    You are assuming that Finder shows you everything. It doesn't. A directory that appears to be empty in Finder won't necessarily be empty.

    Finder doesn't normally show files whose name starts with ".". It creates files named ".DS_Store" to keep view settings in.

    Finder also won't show files which have the "invisible" attribute. These are less common on Mac OS X than they may have been on Classic Mac OS, but a file or folder with the invisible attribute is still not shown by Finder.

    There are also certain files or directories in certain locations that Finder won't show, even though the names don't start with "." and the item doesn't have the invisible attribute. Examples include "etc" and "private" located in the root directory of a mounted volume. There are others; those two are not the entire list.
     
  5. crtvmac thread starter Guest

    Joined:
    Aug 14, 2009
    #5

    I am learning from a book called
    " The Mac OS X Command Line
    Unix Under the Hood"
    By: Kirk McElhearn
    Copyright 2005

    Thanks for the assistance, but I would like to follow the directions in the book if possible. The book illustrates to use 'rm -d -i Test'. Is this a misprint, or am I not understanding what I am reading?
     
  6. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #6
    It's not a misprint, and works fine for me. You should take lee's suggestion and do ls -al first to see if there's actually something there.
     
  7. crtvmac thread starter Guest

    Joined:
    Aug 14, 2009
    #7
    I did 'ls -al'. I got back a lot of drwxr and lrwxr code.
     
  8. LPZ macrumors 65816

    Joined:
    Jul 11, 2006
    #9
    Code:
    rm -d -i Test
    should generate a prompt

    Code:
    remove Test?
    If you respond with Yes---and if Test is empty---then Test will be removed.

    You can read all about the rm command by entering

    Code:
    man rm
    in Terminal.

    Based on your first post, it seems that Test is not empty. I suggest that you try

    Code:
    rm -i -R Test
    instead.
     
  9. crtvmac thread starter Guest

    Joined:
    Aug 14, 2009
    #10
    I did what poster LPZ suggested and I was able to delete the 'Test' directory. I assume it is a matter of understanding the output of 'ls -al' to locate invisible files in directories? Here is the output anyway. Thank for the assistance just the same.

    Myname-Mac-Pro:~ Myname$ ls
    Desktop Library Public
    Documents Movies Send Registration
    Downloads Music Sites
    Java Learning Pictures Test
    Myname-Mac-Pro:~ Myname$ ls -al
    total 48
    drwxr-xr-x+ 18 Myname staff 612 Mar 25 16:16 .
    drwxr-xr-x 5 root admin 170 Mar 24 14:04 ..
    -rw------- 1 Myname staff 3 Mar 24 14:04 .CFUserTextEncoding
    -rw-r--r--@ 1 Myname staff 15364 Mar 25 16:26 .DS_Store
    drwx------ 2 Myname staff 68 Mar 25 16:15 .Trash
    -rw------- 1 Myname staff 578 Mar 25 16:16 .bash_history
    drwx------+ 4 Myname staff 136 Mar 25 15:57 Desktop
    drwx------+ 5 Myname staff 170 Mar 25 15:35 Documents
    drwx------+ 5 Myname staff 170 Mar 25 14:16 Downloads
    drwxr-xr-x 5 Myname staff 170 Mar 25 15:45 Java Learning
    drwx------+ 29Myname staff 986 Mar 25 13:55 Library
    drwx------+ 3 Myname staff 102 Mar 24 14:04 Movies
    drwx------+ 4 Myname staff 136 Mar 24 15:17 Music
    drwx------+ 5 Myname staff 170 Mar 24 15:17 Pictures
    drwxr-xr-x+ 6 Myname staff 204 Mar 24 15:17 Public
    lrwxr-xr-x 1 root staff 57 Mar 24 14:06 Send Registration -> /Users/Myname/Library/Assistants/Send Registration.setup
    drwxr-xr-x+ 5 Myname staff 170 Mar 24 14:04 Sites
    drwxr-xr-x 3 Myname staff 102 Mar 25 16:20 Test
     
  10. crtvmac thread starter Guest

    Joined:
    Aug 14, 2009
    #11
    Your suggestion worked. I had to first delete 'Test/.DS_store'. Then I was able to delete 'Test' directory. Thanks for the assistance.
     

Share This Page