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