Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
what about mv "" "newname"? or maybe the file name is made of spaces ? try ls | wc or something similar –  Kwaio Aug 21 '13 at 9:13
1  
@Kwaio You cannot have a file with an empty name, or at least mv "" would not recognize the empty argument. alk, can you do an inode listing with ls -i? Do you want to move the file or rename it? –  slhck Aug 21 '13 at 9:17
    
How did you get Juni or Jan.. Doesn't look like right. –  user568109 Aug 21 '13 at 10:11
    
@user568109: Juni and Jan. are german. –  alk Aug 21 '13 at 10:40
add comment

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks a lot! find . -inum <inode> -exec mv {} gatya \; did it. Please see my comment on jaychris answer for some background. –  alk Aug 21 '13 at 10:39
add comment

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
share|improve this answer
    
It turned out the file name was ^?. However to grab the file I had to rename it, but wasn't able to enter ^? via the keyboard so I succesfully used the "inode"-approach propose by Daniel Andersson. Thanks anyway. –  alk Aug 21 '13 at 10:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.