If the destination directory does not exist when you attempt to move files using the mv command, you will receive an error message indicating that the destination is not found. The command will not execute successfully, and the files will remain in their original location.
Example Error Message:
mv: cannot move 'file1.txt' to 'nonexistent_directory/': No such file or directory
Solution:
To avoid this error, you should ensure that the destination directory exists before moving the files. You can create the directory using the mkdir command:
mkdir destination_directory
After creating the directory, you can then proceed to move the files:
mv file1.txt file2.txt file3.txt destination_directory/
Alternatively, if you want to create the directory and move the files in one command, you can use the -p option with mkdir to create parent directories as needed:
mkdir -p destination_directory && mv file1.txt file2.txt file3.txt destination_directory/
This command will create the directory if it doesn't exist and then move the specified files into it.
