34

In a terminal window, I typed:

mv filename ..\..      [Note the wrong slash.]

Now I can't find it. Gone. I ran some searches and looked through recoverable deleted files. Nothing. Poof. Serves me right for using a Windows machine right before.

Anyone know where it might have gone?

3
  • find / -iname thefilename -print maybe ? Commented Apr 21, 2015 at 22:17
  • @Serg With thefilename as the files original name, that find command will not find it under the new name. Commented Apr 21, 2015 at 22:27
  • I realized that just after posting the comment. My initial response if a file is missing is to use find but what I didn't realize is that op renamed the file instead of moving it Commented Apr 21, 2015 at 22:39

3 Answers 3

71

It has gone nowhere, its in the current directory. It has been renamed as .... (four dots).

As any filename having a . in front is treated a hidden file, so it has become hidden. So, if you do ls, you won't find it. Like always, you need the -a (or -A) option of ls to view the hidden files i.e. ls -a (or ls -A) to see it.

Let me break it down, you ran mv filename ..\.. , the first two dots would mean the parent directory if it were ../, but you have used backward slash ..\ which indicates shell to escape the next character but a dot . has no special meaning to shell. So, it will treat it as a literal . and the last . also added, so you got four dots .... as a filename.

To revert back to the previous (original) name, run mv .... filename.

2
  • 2
    Hahaha... never occurred to me. There it is: "....". Thanks! I guess it interpreted the first dot as the .hideme dot.
    – John
    Commented Apr 21, 2015 at 22:22
  • 2
    May I suggest la -A (with a capital A). It does the same as ls -a but excludes . and ... Commented Apr 28, 2015 at 8:46
13

Run mv .... filename to rename it back. (mv ..\.. filename would work too, but the \ is superfluous--as it was in your original command.)

  • The file hasn't been deleted, which is why searching for recoverable deleted files didn't find it.
  • Like in Windows, . and .. entries are present in every directory and refer to the "current" and "parent" directories respectively. But unlike in Windows, sequences of more than two dots don't have any special meaning. Though it's unusual, you're perfectly free to name an ordinary file with a name consisting entirely of dots, so long as it is at least three dots long.
  • Unlike in Windows, in Ubuntu the shell uses \ as an escape character, ensuring the shell treats the following character literally rather than giving it a special meaning. The . character has no special meaning in the shell (in particular, the shell is not what's responsible for making the . and .. entries work). Therefore, in your command, \. was equivalent to ..
  • As heemayl says, by default most utilities don't show files and directories whose names start with a .. Since .... starts with ., running ls without the -A or -a flag did not reveal it.
1
  • 1
    That's exactly how I found it. I was wondering why my "\" didn't act as an escape, but ya, nothing to escape so treated normally. Makes sense.
    – John
    Commented Apr 21, 2015 at 22:28
5

it is still in the same directory, just a 'hidden' file now. You can recover it by "mv .... filename".

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .