0

How can I move a file within a directory to the current working directory without renaming?

I can mv a file from current working directory to the parent directory without renaming using the shorthand..

mv file.file ../

To move a file from a directory to the current working directory I've tried..

mv directory/file.file /

but I get permission denied.

However,

mv directory/file.file file.file

works but I have to type out the file name and the autocomplete won't work because the file isn't in the current working directory.

Isn't there a shorthand to specify the current working directory?

Thanks

  • 4
    The current working directory is '.' (a single dot) – Stephen Rauch Jan 17 '17 at 1:35
  • Thanks! I thought I tried that. But I just tried it and of course it works. I knew it was something simple. – deanresin Jan 17 '17 at 1:37
  • Oh and nice job on the question. Shows a lot of thought and that is why you probably won't a lot of duh's.... :-) – Stephen Rauch Jan 17 '17 at 1:39
  • @StephenRauch: You should probably make that into an answer. – Julie Pelletier Jan 17 '17 at 1:48
  • @JuliePelletier OK – Stephen Rauch Jan 17 '17 at 1:51
5

To move a file to the current directory you (as you correctly surmised) need to indicate which directory to move to. This is because mv will note that the destination is a directory and will not rename the file on the way. So the...

Question Is:

How do I denote the current directory on the command line

Answer:

The current working directory is . (a single dot)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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