rm: Test: Directory not empty

Hi,

I typed rm -d -i Test-->y-->rm: Test: Directory not empty, but in fact there is nothing in the folder of Test.

The-Universe:Test LS$ rm -i testfile
remove testfile? y
The-Universe:Test LS$ ls
The-Universe:Test LS$ cd ..
The-Universe:~ LS$ ls
Desktop Downloads Movies Pictures Send Registration Test
Documents Library Music Public Sites dwhelper
The-Universe:~ LS$ rm -d -i Test
remove Test? y
rm: Test: Directory not empty

Why is this so?

Thank you!

Cheers.

 MacBookAir1,1 (The GrandPAir), Mac OS X (10.6.5), ✓1.6GHz ✓80GB SATA Drive ✓SuperDrive ♬Monster Turbine

Posted on Dec 9, 2010 1:29 AM

Reply
16 replies

Dec 9, 2010 7:32 AM in response to MrHoffman

Hi,

Here is the whole code.

Last login: Thu Dec 9 23:10:09 on ttys000
The-Universe:~ LS$ ls
Desktop Movies Send Registration
Documents Music Sites
Downloads Pictures dwhelper
Library Public

The-Universe:~ LS$ mkdir Test
The-Universe:~ LS$ ls
Desktop Movies Send Registration
Documents Music Sites
Downloads Pictures Test
Library Public dwhelper

The-Universe:~ LS$ cd Test
The-Universe:Test LS$ touch testfile (create "testfile")
The-Universe:Test LS$ echo Hello $USER > testfile (write Hello "User's name" in "testfile")
The-Universe:Test LS$ cat testfile
Hello LS
The-Universe:Test LS$ open .
The-Universe:Test LS$ rm -i testfile (delete "testfile")
remove testfile? y
The-Universe:Test LS$ ls (this proved that no more file in the folder "Test")
The-Universe:Test LS$ cd ..
The-Universe:~ LS$ ls
Desktop Movies Send Registration
Documents Music Sites
Downloads Pictures Test
Library Public dwhelper

The-Universe:~ LS$ rm -d -i Test
remove Test? y
rm: Test: Directory not empty

I've created only 1 file which is "testfile" and I've deleted it with "rm -i testfile". How could it be possible to have hidden file?

Thank you!

Cheers.

Dec 9, 2010 8:50 AM in response to (n_n)

How could it be possible to have hidden file?


We skipped a few steps here in the explanation, so here's how you can get into this case...

This most typically arises because you have your test directory open in the GUI.

When you have the GUI accessing the directory, you'll get a .DS_Store file created.

These and other hidden files will show with +ls -a+ or +ls -A+ command switch.

Other tools and other activities can also create hidden files.

Regardless, please enter the ls command as specified (I tend to use +ls -alR+ (lower-A, lower-L, cap-R), and see if there are hidden files around. That's a full listing of the directory and its contents.

Dec 9, 2010 11:15 AM in response to (n_n)

The-Universe:Test LS$ open .


Yes! you used the open . command!

open list the current current directory with a finder panel. Finder may decide to write .DS_Store file.

Not sure when finder writes .DS_Store file. I resized the window & finder didn't write window. When I added a folder, finder immediately wrote .DS_Store.

mac $ touch d2
mac $ echo "hi" | cat >> d2
mac $ ls -la
total 8
drwxr-xr-x 3 mac staff 102B Dec 9 14:05 ./
drwxr-xr-x 90 mac staff 2K Dec 9 14:05 ../
-rw-r--r-- 1 mac staff 3B Dec 9 14:05 d2
mac $ open .
mac $ ls -la
total 8
drwxr-xr-x 3 mac staff 102B Dec 9 14:05 ./
drwxr-xr-x 90 mac staff 2K Dec 9 14:05 ../
-rw-r--r-- 1 mac staff 3B Dec 9 14:05 d2
mac $ open .
mac $ ls -la
total 24
drwxr-xr-x 5 mac staff 170B Dec 9 14:07 ./
drwxr-xr-x 90 mac staff 2K Dec 9 14:05 ../
-rw-r--r-- 1 mac staff 6K Dec 9 14:07 .DS_Store
-rw-r--r-- 1 mac staff 3B Dec 9 14:05 d2
drwxr-xr-x 2 mac staff 68B Dec 9 14:07 untitled folder/
mac $


Robert

------------

PS. You can see the original post format. Reply to post then click on the double quote. You will see the original format of post 🙂 with > added 😟

Here is a copy of the original post.

> {quote:title=(n_n) wrote:}{quote}
> Hi,
>
> Here is the whole code.
>
> Last login: Thu Dec 9 23:10:09 on ttys000
> The-Universe:~ LS$ ls
> Desktop Movies Send Registration
> Documents Music Sites
> Downloads Pictures dwhelper
> Library Public
>
> The-Universe:~ LS$ mkdir Test
> The-Universe:~ LS$ ls
> Desktop Movies Send Registration
> Documents Music Sites
> Downloads Pictures Test
> Library Public dwhelper
>
> The-Universe:~ LS$ cd Test
> The-Universe:Test LS$ touch testfile (create "testfile")
> The-Universe:Test LS$ echo Hello $USER > testfile (write Hello "User's name" in "testfile")
> The-Universe:Test LS$ cat testfile
> Hello LS
> The-Universe:Test LS$ open .
> The-Universe:Test LS$ rm -i testfile (delete "testfile")
> remove testfile? y
> The-Universe:Test LS$ ls (this proved that no more file in the folder "Test")
> The-Universe:Test LS$ cd ..
> The-Universe:~ LS$ ls
> Desktop Movies Send Registration
> Documents Music Sites
> Downloads Pictures Test
> Library Public dwhelper
>
> The-Universe:~ LS$ rm -d -i Test
> remove Test? y
> rm: Test: Directory not empty
>
> I've created only 1 file which is "testfile" and I've deleted it with "rm -i testfile". How could it be possible to have hidden file?
>
> Thank you!
>
> Cheers.


Robert

Dec 10, 2010 11:36 AM in response to (n_n)

I didn't realize how easy it was to list the current directory in the finder:
open .

Thanks...

---------



Here is an overview of the terminal commands. Lets assume that your account has a short user name of mac.
Macintosh-HD -> Applications -> Utilities -> Terminal
#How to list all of your disks.
# The ls command is for li st
mac $ ls /Volumes/
Audio CD Macintosh-HD Spotless Tiger-ext
mac $


# Let's say your flash drive is named Spotless

# cd is change directory
mac $ cd /Volumes/Spotless
# pwd is print working directory
mac $ pwd
/Volumes/Spotless
mac $




# The ls command is for li st
# l is long
# F is type of file where / is directory
mac $ ls -lF
total 134704
-rw-r--r-- 1 mac staff 64560 Mar 3 2009 A-picture-of-Youpi-key.png
drwxr-xr-x 83 mac staff 2822 Nov 7 14:52 Applescript files/
drwxrwxrwx 12 mac staff 408 Dec 13 2008 Christmas Cards/
drwxr-xr-x 9 mac staff 306 Dec 21 17:39 Christmas Cards 2009/
... trimmed ...


What does all this mean?

drwxrwxrwx

d = directory
r = read
w = write
x = executeable program

drwxrwxrwx
| | |
| | all other users not in first two types
| |
| group
|
owner



# l is long
# a is all to show hidden files & folders
mac $ ls -lFa
total 134736
drwxr-xr-x 41 mac staff 1496 Dec 22 17:11 .
drwxrwxrwt 8 root admin 272 Dec 24 13:55 ..
-rwxrwxrwx 1 mac staff 15364 Dec 23 12:52 .DS_Store*
drwx------ 4 mac staff 136 Jan 22 2009 .Spotlight-V100
drwxrwxrwt 5 mac staff 170 Sep 14 16:36 .TemporaryItems
d-wx-wx-wx 4 mac staff 136 Dec 31 1969 .Trashes
-rw-r--r-- 1 mac staff 64560 Mar 3 2009 A-picture-of-Youpi-key.png
drwxr-xr-x 83 mac staff 2822 Nov 7 14:52 Applescript files
drwxrwxrwx 12 mac staff 408 Dec 13 2008 Christmas Cards
drwxr-xr-x 9 mac staff 306 Dec 21 17:39 Christmas Cards 2009

... trimmed ...



# mv is move or rename
mv -i the-name the-new-name

# You can just rename the file back to what it was with mv command.
mv -i old-name new-name

Here is what these commands mean:
cd is change directory
pwd is a print working directory
ls is list
sudo is Super user do
mv is move or rename

For cryptic comments, you can always uses the manual command which is man. For example:
man mv

# Type the letter q to quit.

In case you have spaces in your filenames or directories, you need to escape them. See examples:

mac $ ls -l ~/"see it"
-rw-r--r-- 1 mac staff 3171 Oct 26 23:38 /Users/mac/see it
mac $
mac $ cd /Users/mac/Desktop/ttt\ html\ copy/

Do you know about tabing? Type in a few letters of a name then press the tab key. The computer will type out the rest of the name if it is unique.

Press the up arrow(s) key to see the previous command(s).

history to see many previous commands.

mac $ history
2 man launchd.conf
3 history



Robert

Dec 10, 2010 2:44 PM in response to (n_n)

You may also want to consider the "apropos" command. It parses the intro lines of the man pages (well, technically, I think it searches an already parsed index of the intro lines) and outputs all the man pages matching the search keyword. For example:


$ apropos security
DevToolsSecurity(1) - Change the security authorization policies for developer systems
Net::LDAP::Security(3pm) - Security issues with LDAP connections
acl(3) - introduction to the POSIX.1e ACL security API
audit(4) - Security Event Audit
audit.log(5), audit(5) - Basic Security Module (BSM) file format
gssd(8) - Generic Security Services Daemon
ipsec(4) - IP security protocol
libbsm(3) - Basic Security Module (BSM) Audit API
perlsec(1) - Perl security
permview(1) - Viewer for declarative security permission sets inside assemblies
nmap(1) - Network exploration tool and security / port scanner
ntfs-3g.secaudit(8) - NTFS Security Data Auditing
SecurityPolicy(5) - X Window System SECURITY Extension Policy file format
security(7), Xsecurity(7) - X display access control
DevToolsSecurity(1) - Change the security authorization policies for developer systems

Of course, less specific keywords will generate many, many more lines of output.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

rm: Test: Directory not empty

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.