Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

How can I move a directory whose name is just a space?

ls -lah
drwx------  4 user1 user1 8.0K Mar 13 14:16 .
drwxr-xr-x  3 root  root    60 Mar 13 13:48 ..
drwx------ 18 user1 user1 4.0K Mar 13 11:18  

It's the work of a virus, And I would like to undo it.

Update: I can't know for sure what is that character. As I try to move it like a space, and it doesn't work

$mv ' ' test
mv: cannot stat ` ': No such file or directory
share|improve this question

marked as duplicate by Gilles, jasonwryan, warl0ck, Shadur, Mat Mar 14 '13 at 6:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
I created it and was able to move it with $mv ' ' test Are you using Ubuntu? (I am). –  Michael Durrant Mar 13 '13 at 11:37
    
I'm Fedora linux, but I don't think that's the issue. As I said, it's not actually a space. It's ` ' –  saeed144 Mar 13 '13 at 12:03
    
If it was a virus, don't rename the directory. Nuke the whole installation from orbit (i.e. do a full OS reinstall). –  Gilles Mar 13 '13 at 21:10
add comment

5 Answers 5

up vote 2 down vote accepted

One possible approach is to find the inode number for the directory, and use that to mv it. You don't tell us what platform you are using, so you might need to modify these suggestions to fit the tools available to you (I'm on FreeBSD).

Use your ls utility to get the inode number - the -i switch does that on FreeBSD:

$ ls -i
106739 test

(test is an empty directory I just created to illustrate this solution)

Now, you can use the find utility to find the directory with the inode number:

$ find . -inum 106739
./test

And to move the troublesome directory:

$ find . -inum 106739 -exec mv {} fixed \;
find: ./test: No such file or directory

Don't worry about the error message - it happens because the directory index changes during execution of the command, so find gets a bit confused; the directory has been renamed to fixed:

$ find . -inum 106739
./fixed

As I said, you may need to consult your local documentation to get the right switches, but this approach should work.

share|improve this answer
    
Fixed. Thanks for the hack. I was possible by files explorer through graphical interface. I just wanted to do it in CLI –  saeed144 Mar 13 '13 at 12:22
add comment

You can use:

mv ' ' <where you want to move>
share|improve this answer
add comment

You need to find out what it is called, perhaps by something like

ls | od -c

Other thing to try is something like mv ? somewhere (if the name is one character), mv ?? somewhere (if it has two), ... The above od(1) command should tell the length, or from ls -b output.

If the name really is ' ' (one space), mv ' ' somewhere will work.

share|improve this answer
add comment

You can do this by running these commands:

$ mv " "  ..target..

$ ls -al
-rw-r--r--  1 yupadhya Domain Users..0 Mar 13.. 19:28
drwxr-xr-x+ 1 yupadhya Domain Users     0 Mar 13 19:28 .
drwxrwxrwt+ 1 yupadhya Domain Users     0 Mar 12 10:19 ..
-rwxr-xr-x  1 yupadhya Domain Users  1494 Mar 12 10:16 .bash_profile
-rwxr-xr-x  1 yupadhya Domain Users  6054 Mar 12 10:16 .bashrc

$ mv /home

$ ls -al
total 8
-rw-r--r--  1 yupadhya Domain Users 0 Mar 13 19:28
drwxrwxrwt+ 1 yupadhya Domain Users 0 Mar 13 19:29 .
drwxr-xr-x+ 1 yupadhya Domain Users 0 Mar 12 13:14 ..

$ pwd
/home
share|improve this answer
add comment

Use the dollar symbol to prevent the space character from being parsed, i.e

mv $' ' /path/to/folder

Otherwise it would not be treated as a parameter.

share|improve this answer
add comment

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