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 [email protected]

Unfortunately, this did not work. Worse, my file seems to have disappeared. A new file, [email protected], 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
3  
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 yesterday
    
@HalosGhost If you replace mv with scp you will end up with the same result. You will need to scp to [email protected]: at least. –  Bernhard yesterday
4  
@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 yesterday
29  
"Worse, my file seems to have disappeared. A new file, [email protected], has appeared" What MIGHT be the content of that file? Don't you want to guess? –  glglgl yesterday
2  
@CarlWitthoft: Well, when you "rename", you are just "moving" the file to a new one with a new name :D –  Rocket Hazmat 22 hours ago
show 5 more comments

4 Answers

You have renamed your file to [email protected].Try renaming it back:

mv [email protected] sqlreport.php
share|improve this answer
2  
There's no need to quote the filename with the @ in it. (There wasn't when it was moved to that filename.) –  David Conrad 18 hours ago
add comment

Your file is not vanished,You have just renamed it. You can rename it back to sqlreport.php using the following command mv [email protected] sqlreport.php. To copy your file to remote host you can use the scp command. scp sqlreport.php [email protected]:/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
1  
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 19 hours ago
add comment

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
2  
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 yesterday
2  
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 yesterday
    
@Zack still, even in NTFS there's a POSIX name subsystem. –  Ruslan 12 mins ago
add comment

In your case your file got renamed to [email protected]

Try using scp to copy the file to remote location

share|improve this answer
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.