Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

crtvmac

Guest
Original poster
Aug 14, 2009
85
0
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?
 
what about a little ls -al action in the directory to be deleted? maybe there are some hidden files in there.

-Lee
 
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?

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.
 
you want

Code:
rm -r /path/to/Test

(PS: if you Google your question first you'll get an answer without having to wait)


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?
 
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?

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.
 
Post the output.

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
 
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.

Your suggestion worked. I had to first delete 'Test/.DS_store'. Then I was able to delete 'Test' directory. Thanks for the assistance.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.