To move a file to another folder or directory, we can use the mv
command followed by the source path of the file and then the destination path in Linux.
For example, let's say we have a file called myFile.txt
which we need to move to a directory called myDirectory
, to do that we can use the mv
Linux command like this,
# Move "myFile.txt" to "myDirectory" directory
mv myFile.txt myDirectory
-
In the above command after the
mv
command we have defined the source path of the file which is themyFile.txt
and after that the destination path which is themyDirectory
directory where the file needs to be moved to. -
Executing the above command will move the
myFile.txt
file to themyDirectory
directory or folder.
See the execution of the above command live in repl.it.
That's all 😃!