Search code examples
macosfilemv

What happens when you try to move a file to a non-existant location MAC?


On executing the following lines via the terminal on a MAC, mv terraform2 ~/bin cd ~/bin I get the error that '/Users/myname/bin: Not a directory`. However, I can't see the file terraform2 in its original location. Where did it go?


Solution

  • Given

     mv terraform2 ~/bin
    

    If ~/bin doesn't exist before you run that command, your file terraform2 will be renamed to a file called ~/bin.

    Thus, when you try

    cd ~/bin
    

    you get

    /Users/myname/bin: Not a directory
    

    because it's a file - your original terraform2 file.

    The command

     mv terraform2 ~/bin/.
    

    is much better when you're trying to mv a file into a directory.