To move files with spaces in their names in Linux, you need to either escape the spaces with a backslash (\) or enclose the entire file name in quotes. Here are both methods:
Method 1: Escaping Spaces
You can use a backslash before each space:
mv file\ with\ spaces.txt destination_directory/
Method 2: Using Quotes
You can enclose the file name in single or double quotes:
mv "file with spaces.txt" destination_directory/
or
mv 'file with spaces.txt' destination_directory/
Example:
If you want to move a file named my document.txt to a directory named documents, you can use either of the following commands:
mv my\ document.txt documents/
or
mv "my document.txt" documents/
Both methods will successfully move the file to the specified directory.
