4

I would like to move a file via the terminal using the mv command. The syntax is

mv file_old_dir file_new_dir

I am already in the directory where I want the file moved. I just did mv file_old_dir which didn't work.

How can I do this?

mv file_old_dir "here"

Vader
  • 1,382
  • 2
  • 10
  • 18

2 Answers2

16

You can use the dot (.), the ~+ tilde expansion, the pwd command or the $PWD variable to represent the current working directory (CWD). All these commands can do what you want:

  1. mv file_old_dir .
  2. mv file_old_dir ~+
  3. mv file_old_dir $(pwd)
  4. mv file_old_dir $PWD
0x2b3bfa0
  • 8,780
  • 6
  • 36
  • 55
7

I am going to show some alternate ways using the PWD environment variable and pwd built-in of the shell.

You can the use the value of PWD environment variable that stores the name of current working directory:

mv file_old_dir "$PWD"

Or you can use the pwd built-in of shell that prints the current working directory (basically pwd shows the value of PWD variable by default):

mv file_old_dir "$(pwd)"
heemayl
  • 91,753