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"
2 Answers
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:
mv file_old_dir .mv file_old_dir ~+mv file_old_dir $(pwd)mv file_old_dir $PWD
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)"