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