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.

I was attempting to utilize the mv command to move a file onto a remote server. I ended up executing the command...

mv sqlreport.php myuser@mywebsite.org

Unfortunately, this did not work. Worse, my file seems to have disappeared. A new file, myuser@mywebsite.org, has appeared, but it is not a directory (In that I cannot cd into it).

Any tips on where my file may have gone, and how to rescue it?

share|improve this question

closed as off-topic by devnull, jasonwryan, slm Jun 30 at 4:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – devnull, jasonwryan, slm
If this question can be reworded to fit the rules in the help center, please edit the question.

You went wrong in that mv is not capable of moving a file to a remote location. You will need something like curl or scp. –  HalosGhost Jun 24 at 5:17
@Bernhard, I did not mean to (nor do I feel that I did) imply that either curl or scp were 1:1 replacements for mv using the syntax the OP used. They are, however, tools that can be used for what the OP wants. –  HalosGhost Jun 24 at 6:01
"Worse, my file seems to have disappeared. A new file, myuser@mywebsite.org, has appeared" What MIGHT be the content of that file? Don't you want to guess? –  glglgl Jun 24 at 14:02
@CarlWitthoft: Well, when you "rename", you are just "moving" the file to a new one with a new name :D –  Rocket Hazmat Jun 24 at 17:08
The new file is not a directory? Impressive. Was the old file a directory? –  R. Martinho Fernandes Jun 25 at 15:06

4 Answers 4

You have renamed your file to myuser@mywebsite.org.Try renaming it back:

mv myuser@mywebsite.org sqlreport.php
share|improve this answer
There's no need to quote the filename with the @ in it. (There wasn't when it was moved to that filename.) –  David Conrad Jun 24 at 21:16

Your file is not vanished,You have just renamed it. You can rename it back to sqlreport.php using the following command mv myuser@mywebsite.org sqlreport.php. To copy your file to remote host you can use the scp command. scp sqlreport.php myuser@mywebsite.org:/remote/directory/path. If you want to copy a directory to remote host then you can use -r option suffix to scp.

share|improve this answer
And while we're at it: You need to put at least a colon at the end of the remote target (useful for copying something to a remote home directory) or scp works just like cp. Happens to me all the time and I always wonder briefly why my file isn't there. –  musiKk Jun 24 at 19:51

The key insight is that, in Unix, a filename can contain any character at all, except for '/' and the null character. So, when you type mv file user@host, it moves file file to file user@host, even though the new name contains funny characters such as '@' and '.'.

(As per MvG's comment, things get a little more complex in the brave new world of Unicode but, for 8-bit character sets, the above remains true.)

share|improve this answer
Better make that “any byte at all”, since the interpretation as characters depends on locale. In some encodings, UTF-8 for example, there might even be byte combinations which don't correspond to characters. –  MvG Jun 24 at 14:54
Yep. As far as the kernel is concerned, pathnames are arbitrary strings of bytes, and the only bytes with any defined meaning are 0x2f (ASCII /, component separator) and 0x00 (end of C-string). Defining a general mapping of these byte sequences to character sequences is entirely user space's problem. (Some filesystems, e.g. NTFS, impose more complicated rules, coming as they do from OSes with more complicated pathname semantics.) –  Zack Jun 24 at 15:17
@Zack still, even in NTFS there's a POSIX name subsystem. –  Ruslan Jun 25 at 15:21

In your case your file got renamed to myuser@mywebsite.org

Try using scp to copy the file to remote location

share|improve this answer

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