Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File and directory with same name in same parent directory - Solaris 8, ufs

Ok, I have been working with Solaris for a 10+ years, and have never seen this...

I have a directory listing which includes both a file and subdirectory with the same name:

-rw-r--r--   1 root     other    15922214 Nov 29  2006 msheehan
drwxrwxrwx  12 msheehan sysadmin    2048 Mar 25 15:39 msheehan

I use file to discover contents of the file, and I get:

bash-2.03# file msheehan
msheehan:       directory
bash-2.03# file msh*
msheehan:      ascii text
msheehan:       directory

I am not worried about the file, but I want to keep the directory, so I try rm:

bash-2.03# rm msheehan
rm: msheehan is a directory

So here is my two part question:

  1. What's up with this?
  2. How do I carefully delete the file?

Jonathan

Edit: Thanks for the answers guys, both (so far) were helpful, but piping the listing to an editor did the trick, ala:

bash-2.03# ls -l > jb.txt
bash-2.03# vi jb.txt

Which contained:

-rw-r--r--   1 root     other    15922214 Nov 29  2006 msheehab^?n
drwxrwxrwx  12 msheehan sysadmin    2048 Mar 25 15:39 msheehan

Always be careful with the backspace key!

like image 510
Jonathan Bourke Avatar asked Mar 02 '23 07:03

Jonathan Bourke


2 Answers

I would guess that these are in fact two different filenames that "look" the same, as the command file was able to distinguish them when the shell passed the expanded versions of the name in. Try piping ls into od or another hex/octal dump utility to see if they really have the same name, or if there are non-printing characters involved.

like image 169
wnoise Avatar answered Apr 26 '23 00:04

wnoise


I'm wondering what could cause this. Aside from filesystem bugs, it could be caused by a non-ascii chararacter that got through somehow. In that case, use another language with easier string semantics to do the operation.

It would be interesting to see what would be the output of this ruby snippet:

ruby -e 'puts Dir["msheehan*"].inspect'
like image 36
bltxd Avatar answered Apr 26 '23 01:04

bltxd