Numpty question - why did this happen? (mv command)

Discussion in 'Linux' started by larkim, May 7, 2009.

  1. larkim

    larkim

    Joined:
    Apr 24, 2009
    Messages:
    60
    Likes Received:
    0
    Feeling a little sheepish here. I don't consider myself to be a complete Linux newbie (I used Unix based machines as long ago as 1991), but I've clearly got very very rusty!

    I wanted to move a file (using terminal) from one directory to another (from Documents to Documents\Videos actually).

    Every time I issued "mv Filename.mpg \Videos\Filename.mpg" it didn't move it, instead it renamed the existing file as "VideosFilename.mpg".

    Realising I used the wrong command, I foolishly (as it turned out) typed "mv Filename.mpg ..\Videos\Filename.mpg". The file disappeared (!) from the Documents directory, but hasn't reappeared anywhere else! Now, I know I got it wrong. Presumably a combination of using backslashes instead of forward slashes, plus incorrect use of the parent directory (..). But can someone explain why it appears to have deleted the file completely?

    (And presumably the right syntax was "mv Filename.mpg ~/Videos/Filename.mpg"?

    Matt
     
    larkim, May 7, 2009
    #1
  2. larkim

    ronime

    Joined:
    Nov 3, 2008
    Messages:
    486
    Likes Received:
    0
    Location:
    West Yorkshire, UK
    The file is probably still there. "ls" hides filenames beginning with "." by default. Try:

    ls -ld .*
     
    ronime, May 7, 2009
    #2
  3. larkim

    adjektiivi

    Joined:
    Mar 22, 2009
    Messages:
    43
    Likes Received:
    0
    Location:
    Finland
    exeample

    i wanna move pic to other place
    Code:
    sudo mv /home/user/home_internet_wallpaper.jpg /opt/xandros/share/AsusLauncher
    Code:
    mv myfile mynewfilename    renames a file
    mv myfile otherfilename    renames a file and deletes the existing file "myfile"
    mv myfile /myfile          moves 'myfile' from the current directory to the root directory
    mv myfile dir/myfile       moves 'myfile' to 'dir/myfile' relative to the current directory
    mv myfile dir              same as the previous command (the filename is implied to be the same)
    mv myfile dir/myfile2      moves 'myfile' to dir and renames it to 'myfile2'
    mv foo bar baz dir         moves multiple files to directory dir
    mv --help                  shows a very concise help about the syntax of the command
    man mv                     prints an extensive user manual for 'mv' in the terminal
     
    adjektiivi, May 7, 2009
    #3
  4. larkim

    larkim

    Joined:
    Apr 24, 2009
    Messages:
    60
    Likes Received:
    0
    Fab. ls -ld .* revealed all. Now properly renamed and moved!

    Matt
     
    larkim, May 7, 2009
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.