rmdir dir gives error 'Not a directory'

sprite

I have what looks to be a directory directory dir2, I once moved it from another directory dir1 to back it up and created a new dir1.

Now I suddenly saw it again, realized I didn't need it and did rm -r -f dir2, and found out that my new dir1 is also empty.

I got my files back (is was a code repository, so just some changes lost - bummer), but I still want to remove this redundant link or whatever dir2 is.

When I tried rmdir (before I realized I deleted everything) I got an error Not a directory. What is it and how do I remove it? Using bash on OSX terminal.

Update: Per suggestions below:

ls -ld dir2 outputs drwxr-xr-x. 19 asaf users 4096 Mar 8 13:09 dir2/

file dir2/ outputs dir2/: directory

file dir2 outputs dir2: symbolic link to ...'

Gilles 'SO- stop being evil'

It's impossible to know what happened given that the evidence is now deleted. Your descriptions of the symptoms is consistent with dir2 being a symbolic link to a directory. A symbolic link is a sort of special file that says “the real file is actually over there”. The symbolic link itself isn't a directory, so rmdir can't do anything with it. But accesses to the content of the symbolic link (files in the directory for a symbolic link pointing to a directory, file contents for a symbolic link pointing to a regular file) go to the target of the link transparently, so you wouldn't have noticed anything when using cd dir2 or when editing files in the directory.

If this is the case (which is plausible, but not at all certain!), then the command rm -r -f dir2 only deleted the symbolic link, and the directory containing your changes still exists… somewhere. Since you've deleted the link, it might be difficult to find where, but you can try looking for the file names that you know were in that directory with the locate command or with an equivalent GUI (Spotlight?).

In the future, run

ls -ld dir2

That would tell you what kind of file dir2 is. If the line begins with d, it's a directory. If the line begins with l, it's a symbolic link, and the output indicates where it points to (the part after ->).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Setting hadoop.tmp.dir on Windows gives error: URI has an authority component

Git bash giving error of warning: unable to rmdir

getting "ENOTEMPTY: directory not empty, rmdir ....." error on installing express in angular CLI app.

local header files available in the project but make gives No such file or directory error

umap collectstatic gives "No such file or directory" error

Nginx Virtual Directory using the same root gives 404 error

soci gives fatal error: mysql.h: No such file or directory

NextPageToken gives invalid input error, 400 - Google Directory API ChomeDevices

How to solve yarn build error - Error: ENOTEMPTY: directory not empty, rmdir '/frontend/out/node_modules/cacache/node_modules/.bin'

Bash script to display directory listing gives error

$ find -exec cd => gives error: => find: ‘cd’: No such file or directory

hadoop version command gives error related to java (No such file or directory)

launchd gives me " No such file or directory" error

Creating a symlink gives cannot overwrite directory error

Changing UUID with tune2fs gives "NOT A DIRECTORY" ERROR

rmdir failed to remove empty directory

unzip: gives: checkdir error: .../directory exists but is not a directory

Trying to remove current directory using rmdir

On Hadoop installation, bash: gives an 'is a directory error'

Write to a file on docker container gives error: No such file or directory

scp gives "[file] not a directory" error when using parameters

Concatenating files from a directory using cat gives "No such file or directory" error

Git diff gives 'No such path' error when I specify a directory

copying * files in Docker to directory gives error

vscode installed in other directory gives access denied error

#1010 - Error dropping database (can't rmdir './my_ucf_database', errno: 39 "Directory not empty") What do I do to drop this database?

pytorch gives me an error when I don't run it in ~/ directory

Directory name error when creating dir in python out of the blue

`gn gen` gives `ERROR Need exactly one build directory to generate`