4

I have this situation in a certain directory:

$ ls -al
...
drwxr-xr-x   2 me users         8192 Juni 28 15:27 tmp
-rw-r--r--   1 me users          439 Jan.  3  2013
...

How can I access the second entry, which appears to have no filename?

alk
  • 167

2 Answers2

7

A sample run to create a file named "non breaking space" and renaming it:

$ ls -1 # Each file on a separate row
testfile
$ touch   # I'm actually writing the character u00a0 here
$ ls -1
testfile
 
$ ls -i # Print inodes
2031842 testfile
2023653  
$ find . -maxdepth 1 -inum 2023653 -exec mv {} hithere \;
$ ls -i1
2023653 hithere
2031842 testfile

The exec in its form only makes sense if there is just a single match, but the inode number should be unique on that partition unless there exists hard links to the same file. You can test this by running find without arguments first to see if you get multiple matches. If that is the case, you can e.g. refine the find pattern to only match the file you want.

Since the renaming does not depend on the exact characters of the filename, there should be no problem with entering strange code points.

2

I would try "ls -1a > /tmp/list" and hexdump to see if something comes up. It is possible the file name is sequence of spaces and tabs. If the hexdump shows the filename as spaces (say 1 space), then do a "mv \ somename"

ls -1

ls -1 > /tmp/list
cat /tmp/list

hexdump /tmp/list
          00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F  0123456789ABCDEF

00000000  20 0A     {------                                          .
mv \  new        {------
ls -1
new
jaychris
  • 378